dshell 1.0.2 copy "dshell: ^1.0.2" to clipboard
dshell: ^1.0.2 copied to clipboard

discontinuedreplaced by: dcli
outdated

A bash replacement allow you to write bash like scripts using dart.

example/example.dart

import 'package:dshell/dshell.dart';

void main() {
  Settings().debug_on = true;

  // Print the current working directory
  print("PWD: ${pwd}");

  // Change to the directory 'main'
  cd("main");

  // Create a directory with any needed parents.
  makeDir("tools/images", createParent: true);

  // Push the current directory onto the stack
  // and change directory.
  push("tools/images");

  // create a file (its empty)
  touch("good.jpg", create: true);

  // update the last modified time on an existing file
  touch("good.jpg");

  // I think you know this one.
  echo("All files");

  // print out all files in the current directory.
  // fileList is a DShell property.
  for (var file in fileList) {
    print(file);
  }

  // take a nap for a couple of seconds.
  sleep(2);

  echo("Find file matching *.jpg");
  // Find all files that end with .jpg
  // in the current directory and any subdirectories
  for (var file in find("*.jpg")) {
    print(file);
  }

  // Move/rename a file
  move("good.jpg", "bad.jpg");

  // check if a file exists.
  if (exists("bad.jpg")) {
    print("bad.jpg exists");
  }

  // Delete a file asking the user first.
  delete("bad.jpg", ask: false);

  // return to the directory we were in
  // before we called push above.
  pop();

  // Print out our current working directory.
  echo(pwd);
}
28
likes
0
pub points
7%
popularity

Publisher

verified publishernoojee.org

A bash replacement allow you to write bash like scripts using dart.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

args, file_utils, intl, logger, path, pedantic, recase, yaml

More

Packages that depend on dshell