nom: initial raku tool and library experiments

wip/yesman
Katharina Fey 3 years ago
parent c9ca3395ba
commit 0b4197ab63
Signed by: kookie
GPG Key ID: 90734A9E619C8A6C
  1. 1
      infra/nom/.envrc
  2. 13
      infra/nom/clap/README.md
  3. 39
      infra/nom/clap/lib/Clap/Clap.rakumod
  4. 11
      infra/nom/clap/test.raku
  5. 7
      infra/nom/main.raku
  6. 6
      infra/nom/shell.nix

@ -0,0 +1 @@
eval "$(lorri direnv)"

@ -0,0 +1,13 @@
# Command Line Argument Parser
A flexible CLI parser for raku. Inspired by
[clap.rs](https://clap.rs)!
## Usage
Install clap with zef!
```console
$ zip install clap
```

@ -0,0 +1,39 @@
unit module Clap;
say "Loading clap...";
class Subcommand is export {
has Str $.name;
has Str $.about is rw;
method with_name(Str $name) returns Subcommand {
return self.bless(:$name);
}
method about(Str $about) returns Subcommand {
$!about = $about;
return self;
}
}
class App is export {
has Str $.about is rw;
has Str $.author is rw;
has @.subs is rw = Array.new();
method about(Str $about) returns App {
$!about = $about;
return self;
}
method author(Str $author) returns App {
$!author = $author;
return self;
}
method subcommand(Subcommand $cmd) returns App {
@.subs.push($cmd);
return self;
}
}

@ -0,0 +1,11 @@
use lib 'lib/Clap';
use Clap;
my $app = App.new()
.about("This is some about text")
.author("Katharina Fey <kookie@spacekookie.de>")
.subcommand(Subcommand
.with_name("build")
.about("Do some thing"));
say $app;

@ -0,0 +1,7 @@
## kookieNOMicon manager
#
#
sub MAIN() {
}

@ -0,0 +1,6 @@
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "nom";
buildInputs = with pkgs; [ rakudo zef ];
}
Loading…
Cancel
Save