dshell 1.0.3 dshell: ^1.0.3 copied to clipboard
A bash replacement allow you to write bash like scripts using 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);
}