Skip to content

Instantly share code, notes, and snippets.

@niner
Created September 6, 2017 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niner/a75aebd0e91af200df21b233d82aa5af to your computer and use it in GitHub Desktop.
Save niner/a75aebd0e91af200df21b233d82aa5af to your computer and use it in GitHub Desktop.
use v6.c;
use Test;
use Native::Command;
sub true() is command { * }
sub ls($dir?, :$l, :$help) is command { * }
is(true().run.exitcode, 0);
# long switches :help -> --help
is(ls(:help).run(:out).exitcode, 0);
like(ls(:help).run(:out).out.lines[0], /Usage/);
# positionals will follow switches
is(ls('lib').run(:out).out.lines[0], 'Native');
# shortcut for a very common case, same as above
is(ls('lib').out.lines[0], 'Native');
# short switch (just 1 character) :l -> -l
like(ls('lib', :l).run(:out).out.lines[0], /total/);
done-testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment