Skip to content

Repository files navigation

dsh

A small Dart library for writing scripts that feel like shell scripts, plus the scripts I actually use.

Each file in apps/ is one command. make compiles it to a .dill and writes a tiny shell wrapper around it.

The library

lib/dartsh.dart covers the boring parts of a script: running a process and reading what it printed, parsing arguments, reading the environment, writing output, and bailing out with an error. Import it as sh and the code reads close to the shell version.

import 'package:dartsh/dartsh.dart' as sh;

Future<void> main() async {
  final taps = await sh.run('brew', ['tap']);
  if (!taps.ok) sh.fail(taps.stderr);
  sh.emit(taps.lines);
}

Build and install

dart pub get
make stage      # compile apps into build/
make install    # copy wrappers to ~/bin and dills to ~/bin/scripts
make uninstall

Set PREFIX to install somewhere else. While hacking, dart run apps/sleepctl.dart skips the build.

To add a command, drop a file in apps/ and run make again. That's it.

About

Tiny helper library and staging workspace for Dart command-line scripts.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages