dcli
  • Introduction
  • What does DCli do?
  • Install DCli
    • Installing on Windows
  • Writing your first CLI app
  • Add DCli to your project
  • pub.dev
  • github
  • Dart basics
    • Dart lambda functions
    • Function Arguments
    • Futures
    • stdin/stdout/stderr a primer
  • Tour
    • Overview
    • Using DCli functions
    • User input
      • Ask Validators
    • Displaying information
    • Managing Files And Directories
    • Environment variables
    • Calling apps
    • Redirecting output
    • Command Line Arguments
    • Paths
    • Glob Expansion
    • Piping
    • Locking
    • Fetch
    • The evils of CD
    • Assets/Resources
    • Cross Platform
      • Posix
      • Windows
      • Docker
        • Detecting Docker
        • Add DCli to a Docker Container
        • Example DCli app in Docker
  • Elevated Privileges
    • Sudo
  • Performance
  • Dependency Management
    • Dependency Management
    • Pubspec Managment
  • DCli Tools
    • DCli tools
    • Use a shebang #!
    • DCli Compile
    • DCli Clean
    • DCli Create
    • DCli Doctor
    • DCli Install
    • DCli Run
    • DCli Warmup
    • DCli Pack
    • Upgrade DCli
  • Internal Workings
    • Internal Workings
    • waitForEx
  • Contributing
    • Creating a release
    • Running Unit tests
    • Implemention support for a shell
    • Templates
  • References
  • Examples
    • Projects
    • Code
      • hello world.
      • dcompress
      • dpath
      • dmysql
      • dshell
      • dwhich
      • dipaddr
      • gnome launcher
  • Articles
    • build CLI apps in dart - part 1
    • build CLI apps in dart - part 2
    • Dealing with permissions
    • 3rd Party console packages
  • Dart on Linux - the perfect CLI tooling
  • Improving your build environment
    • Existing tooling
    • Building with Dart
    • A home for your build tools
  • Olivier Revial - CLI apps made easy
  • Video: package of the week
Powered by GitBook
On this page
  • Sponsored by OnePub
  • Overview
  • So why DCli?
  • Example:
  • So why is DCli different?

Was this helpful?

Introduction

NextWhat does DCli do?

Last updated 9 months ago

Was this helpful?

DCli is the console SDK for Dart.

Use the DCli console SDK to build cross platform, command line (CLI) applications and scripts using the Dart programming language.

The DCli (pronounced d-kleye) console SDK includes command line tools and an extensive API for building CLI apps.

The DCli console SDK as featured on Jermaine Oppong package of the week vlog.

Sponsored by OnePub

OnePub allows you to privately share Dart packages across your Team and with your customers.

Try it for free and publish your first private package in seconds.

Publish a private package in six commands:

dart pub global activate onepub

onepub login

dcli create --template=full mytool

cd mytool

onepub pub private

dart pub publish

You can now install mytool on any system with dart installed:

dart pub global activate onepub
onepub login
onepub pub global activate mytool

Overview

The DCli console SDK is intended to to allow you to create Command Line (CLI) Applications from simple scripts to full-blown CLI apps.

DCli is a great replacement for CLI apps that would have traditionally been built with Bash, C, Python, Ruby, Go, Rust ....

Whether it's a 5 line Bash script or a 100,000 line production management system (like we run internally) DCli is the right place to start building your CLI infrastructure.

So why DCli?

DCli is based on Dart which is a modern programming language that has a set of features that makes building CLI apps easy and reliable.

  • Dart and DCli are simple to learn

  • Compiled or JIT

  • Shebag support (run .dart scripts directly from the terminal ./hellow.dart)

  • Small transportable execs (from 10MB) and the Dart VM is NOT required on the target system.

  • Typesafe language catches errors at compile time

  • Sound null safety reduces null pointer exceptions

  • Fast

  • Great development environment using vs-code

  • Local and Remote development/debugging

  • Cross-platform supporting Linux/Windows/MacOS/ARM

Example:

#! /usr/bin/env dcli

import 'dart:io';
import 'package:dcli/dcli.dart';

void main() async {
  var name = ask('name:', required: true, validator: Ask.alpha);
  print('Hello $name');
  
  print('Here is a list of your files');
  find('*').forEach(print);
  
  print('let me copy your files to a temp directory');
  await withTempDirAsync((pathToTempDir) async {
      moveTree(pwd, pathToTempDir);
  });
}

To run the above script called hello.dart:

./hello.dart

So why is DCli different?

You can now use Dart to build GUI's on Android, IOS, Windows, OSX, Linux. Dart is also suitable for building Web Servers and server-side applications and of course, with DCli you can also target console apps.

Imagine the benefits of using a single language across your complete ecosystem.

Dart is simple to learn and uses the all too familiar 'C' style syntax. I've heard Dart described as the love child of Java and JavaScript. If you come from either of these environments you will find Dart easy to work with.

Dart is the love child of Java and JavaScript and is delightful to work with.

Being easy to learn also helps with the maintenance cycle of your CLI apps. You no longer need a specialized developer, as anyone who has even a vague familiarity with Java, Javascript, or C, ... will be right at home with Dart in a couple of days.

Dart and DCli are easy to install; DCli makes it a breeze to create simple scripts and provides the tools to manage a script that started out as 100 lines but somehow grew to 10,000 lines.

Dart is fast and if you need even more speed it can be compiled into a single file executable that is portable between binary-compatible machines.

# compile, install to the local PATH and run hello.dart
$> dcli compile --install hello.dart
$> hello
name: brett
Hello brett

# copy to a remote machine (where dart is NOT installed)
$> scp hello remote.domain.com:

# login to remote machine and run the app hello
$> ssh remote.domain.com
./hello
name: brett
Hello brett

You can use your favorite editor to create DCli scripts. Vi or VIM work fine but Visual Code is recommended.

Use Visual Code for the best development experience with Dart.

Visual Code with the dart-code extension provides a great development and debugging experience including the ability to develop and debug code on a remote server.

Help support DCli by supporting , the private dart repository.

DCli is based on the relatively new programming language; .

Dart is currently the and is the basis on which Flutter is built.

The installer is now based on Flutter and Flutter will be the primary platform for building GUI's on Ubuntu.

Dart has a large and growing ecosystem of third-party that you can include in your CLI app with no more than an import statement and a dependency declaration.

OnePub
Dart
fastest growing language on github
Ubuntu
libraries