Skip to content

Instantly share code, notes, and snippets.

View bsutton's full-sized avatar

Brett Sutton bsutton

  • @mention onepub
  • Melbourne, Australia
  • 14:28 (UTC +10:00)
View GitHub Profile
@bsutton
bsutton / duntar.dart
Last active January 25, 2020 06:32
Untar a file without having to remember the switches.
#! /usr/bin/env dshell
import 'dart:io';
import 'package:dshell/dshell.dart';
/// duntar <tarfile>
/// untars a file
void main(List<String> args) {
var parser = ArgParser();
var results = parser.parse(args);
import 'dart:async';
import 'dart:convert';
import 'dart:io';
void main() async {
var ls = await start('ls');
var head = await start('head');
var headStdout = head.stdout;
@bsutton
bsutton / which.dart
Last active January 25, 2020 06:00
which.dart
#! /usr/bin/env dshell
import 'dart:io';
import 'package:dshell/dshell.dart';
/// dwhich appname - searches for 'appname' on the path
void main(List<String> args) {
var parser = ArgParser();
parser.addFlag('verbose', abbr: 'v', defaultsTo: false, negatable: false);
var results = parser.parse(args);
@bsutton
bsutton / args.dart
Last active January 13, 2020 19:52
arguments
#! /usr/bin/env dshell
import 'dart:io';
import 'package:dshell/dshell.dart';
void main(List<String> args) {
print('${args.length} were passed');
int index = 0;
for (var arg in args)
{
@bsutton
bsutton / args.dart
Created January 13, 2020 19:51
arguments
#! /usr/bin/env dshell
import 'package:dshell/dshell.dart';
void main(List<String> args) {
print('${args.length} were passed');
int index = 0;
for (var arg in args)
{
print('arg $index = $arg);
@bsutton
bsutton / grep_foreach.dart
Created January 13, 2020 09:38
grep forEach
#! /usr/bin/env dshell
import 'package:dshell/dshell.dart';
void main() {
'grep error /var/log/syslog'.forEach((line) => print(line));
'grep error /var/log/syslog'.forEach((line) { print('matched $line'); });
'grep error /var/log/syslog'.forEach((line) => print(line), stderr:(line) => print(red(line)));
}
@bsutton
bsutton / grep.dart
Last active January 14, 2020 10:21
grep run
#! /usr/bin/env dshell
import 'package:dshell/dshell.dart';
void main() {
'grep error /var/log/syslog'.run;
}
@bsutton
bsutton / dshell_create.sh
Last active January 13, 2020 11:42
dshell create
dshell create hellow.dart
Creating project.
Created Virtual Project at /home/bsutton/.dshell/cache/home/bsutton/git/dshell/test/test_scripts/hellow.project
Running pub get...
Resolving dependencies...
+ args 1.5.2
+ charcode 1.1.2
+ collection 1.14.12
+ dshell 1.0.36
+ equatable 1.0.2
@bsutton
bsutton / dshell_install.sh
Created January 13, 2020 07:39
install dshell
chmod +x hello_world.dart
./hello_world.dart
@bsutton
bsutton / hello_world.dart
Created January 13, 2020 07:31
Hello world
#! /usr/bin/env dshell
import 'package:dshell/dshell.dart';
void main() {
print('Hello World');
}