Search…
Introduction
DCli is an SDK for for building cross platform command line (CLI) applications and scripts using the Dart programming language.
The DCli (pronounced d-cli) SDK is includes command line tools and an extensive api for for building cli apps.
Looking for DShell? You are in the right place. DShell has been renamed DCli.
The DCli SDK as featured on Jermaine Oppong package of the week vlog.

Another Dart Tool by Noojee

Overview

The DCli 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 its 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 cli ./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:

1
#! /usr/bin/env dcli
2
3
import 'dart:io';
4
import 'package:dcli/dcli.dart';
5
6
void main() {
7
var name = ask('name:', required: true, validator: Ask.alpha);
8
print('Hello $name');
9
10
}
Copied!
To run the above script called hello.dart:
1
./hello.dart
Copied!

So why is DCli different?

DCli is based on the relatively new programming language; Dart.
Dart is currently the fastest growing language on github and is the basis on which Flutter is built.
Ubuntu has just announced that Flutter will be the primary platform for building GUI's on Ubuntu and is currently working on replacing the Ubuntu installer using Flutter.
You can now use Dart to build GUI's on Android, IOS, Windows, OSX, Linux and the Web, server side applications and with DCli you can also target console apps.
Imagine the benefits of using a single language across you complete ecosystem.
Dart is a 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 you CLI apps. You no longer need a specialised developer, as anyone that 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 has a large and growing ecosystem of third party libraries that you can include in your CLI app with no more than an import statement and a dependency declaration.
Dart is fast and if you need even more speed it can be compiled to a single file executable that is portable between binary compatible machines.
1
# compile, install to the local PATH and run hello.dart
2
gt; dcli compile --install hello.dart
3
gt; hello
4
name: brett
5
Hello brett
6
7
# copy to a remote machine (where dart is NOT installed)
8
gt; scp hello remote.domain.com:
9
10
# login to remote machine and run the app hello
11
gt; ssh remote.domain.com
12
./hello
13
name: brett
14
Hello brett
Copied!
You can use your favourite 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 provide a great development and debugging experience including the ability to develop and debug code on a remote server.
Last modified 16d ago