-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,654 additions
and
1,658 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,30 +33,30 @@ import weaver.Param | |
main! = \args -> | ||
data = | ||
Cli.parse_or_display_message cli_parser args Arg.to_os_raw | ||
|> try Result.onErr! \message -> | ||
try Stdout.line! message | ||
Err (Exit 1 "") | ||
Cli.parse_or_display_message(cli_parser, args, Arg.to_os_raw) | ||
|> try(Result.on_err!(\message -> | ||
try(Stdout.line!(message)) | ||
Err(Exit(1, "")))) | ||
try Stdout.line! "Successfully parsed! Here's what I got:" | ||
try Stdout.line! "" | ||
try Stdout.line! (Inspect.toStr data) | ||
try(Stdout.line!("Successfully parsed! Here's what I got:")) | ||
try(Stdout.line!("")) | ||
try(Stdout.line!(Inspect.to_str(data))) | ||
Ok {} | ||
Ok({}) | ||
cli_parser = | ||
{ Cli.weave <- | ||
alpha: Opt.u64 { short: "a", help: "Set the alpha level." }, | ||
force: Opt.flag { short: "f", help: "Force the task to complete." }, | ||
file: Param.maybe_str { name: "file", help: "The file to process." }, | ||
files: Param.str_list { name: "files", help: "The rest of the files." }, | ||
alpha: Opt.u64({ short: "a", help: "Set the alpha level." }), | ||
force: Opt.flag({ short: "f", help: "Force the task to complete." }), | ||
file: Param.maybe_str({ name: "file", help: "The file to process." }), | ||
files: Param.str_list({ name: "files", help: "The rest of the files." }), | ||
} | ||
|> Cli.finish { | ||
|> Cli.finish({ | ||
name: "basic", | ||
version: "v0.1.0", | ||
authors: ["Some One <[email protected]>"], | ||
description: "This is a basic example of what you can build with Weaver. You get safe parsing, useful error messages, and help pages all for free!", | ||
} | ||
}) | ||
|> Cli.assert_valid | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,28 +11,28 @@ import weaver.Param | |
|
||
main! = \args -> | ||
data = | ||
Cli.parse_or_display_message cli_parser args Arg.to_os_raw | ||
|> try Result.onErr! \message -> | ||
try Stdout.line! message | ||
Err (Exit 1 "") | ||
Cli.parse_or_display_message(cli_parser, args, Arg.to_os_raw) | ||
|> try(Result.on_err!, \message -> | ||
try(Stdout.line!, message) | ||
Err(Exit(1, ""))) | ||
|
||
try Stdout.line! "Successfully parsed! Here's what I got:" | ||
try Stdout.line! "" | ||
try Stdout.line! (Inspect.toStr data) | ||
try(Stdout.line!, "Successfully parsed! Here's what I got:") | ||
try(Stdout.line!, "") | ||
try(Stdout.line!, Inspect.to_str(data)) | ||
|
||
Ok {} | ||
Ok({}) | ||
|
||
cli_parser = | ||
{ Cli.weave <- | ||
alpha: Opt.u64 { short: "a", help: "Set the alpha level." }, | ||
force: Opt.flag { short: "f", help: "Force the task to complete." }, | ||
file: Param.maybe_str { name: "file", help: "The file to process." }, | ||
files: Param.str_list { name: "files", help: "The rest of the files." }, | ||
alpha: Opt.u64({ short: "a", help: "Set the alpha level." }), | ||
force: Opt.flag({ short: "f", help: "Force the task to complete." }), | ||
file: Param.maybe_str({ name: "file", help: "The file to process." }), | ||
files: Param.str_list({ name: "files", help: "The rest of the files." }), | ||
} | ||
|> Cli.finish { | ||
|> Cli.finish({ | ||
name: "basic", | ||
version: "v0.0.1", | ||
authors: ["Some One <[email protected]>"], | ||
description: "This is a basic example of what you can build with Weaver. You get safe parsing, useful error messages, and help pages all for free!", | ||
} | ||
}) | ||
|> Cli.assert_valid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,60 +12,60 @@ import weaver.SubCmd | |
|
||
main! = \args -> | ||
data = | ||
Cli.parse_or_display_message cli_parser args Arg.to_os_raw | ||
|> try Result.onErr! \message -> | ||
try Stdout.line! message | ||
Err (Exit 1 "") | ||
Cli.parse_or_display_message(cli_parser, args, Arg.to_os_raw) | ||
|> try(Result.on_err!, \message -> | ||
try(Stdout.line!, message) | ||
Err(Exit(1, ""))) | ||
|
||
try Stdout.line! "Successfully parsed! Here's what I got:" | ||
try Stdout.line! "" | ||
try Stdout.line! (Inspect.toStr data) | ||
try(Stdout.line!, "Successfully parsed! Here's what I got:") | ||
try(Stdout.line!, "") | ||
try(Stdout.line!, Inspect.to_str(data)) | ||
|
||
Ok {} | ||
Ok({}) | ||
|
||
cli_parser = | ||
{ Cli.weave <- | ||
force: Opt.flag { short: "f", help: "Force the task to complete." }, | ||
sc: SubCmd.optional [subcommand_parser1, subcommand_parser2], | ||
file: Param.maybe_str { name: "file", help: "The file to process." }, | ||
files: Param.str_list { name: "files", help: "The rest of the files." }, | ||
force: Opt.flag({ short: "f", help: "Force the task to complete." }), | ||
sc: SubCmd.optional([subcommand_parser1, subcommand_parser2]), | ||
file: Param.maybe_str({ name: "file", help: "The file to process." }), | ||
files: Param.str_list({ name: "files", help: "The rest of the files." }), | ||
} | ||
|> Cli.finish { | ||
|> Cli.finish({ | ||
name: "subcommands", | ||
version: "v0.0.1", | ||
authors: ["Some One <[email protected]>"], | ||
description: "This is a basic example of what you can build with Weaver. You get safe parsing, useful error messages, and help pages all for free!", | ||
} | ||
}) | ||
|> Cli.assert_valid | ||
|
||
subcommand_parser1 = | ||
{ Cli.weave <- | ||
d: Opt.maybe_u64 { short: "d", help: "A non-overlapping subcommand flag with s2." }, | ||
volume: Opt.maybe_u64 { short: "v", long: "volume", help: "How loud to grind the gears." }, | ||
sc: SubCmd.optional [sub_subcommand_parser1, sub_subcommand_parser2], | ||
d: Opt.maybe_u64({ short: "d", help: "A non-overlapping subcommand flag with s2." }), | ||
volume: Opt.maybe_u64({ short: "v", long: "volume", help: "How loud to grind the gears." }), | ||
sc: SubCmd.optional([sub_subcommand_parser1, sub_subcommand_parser2]), | ||
} | ||
|> SubCmd.finish { name: "s1", description: "A first subcommand.", mapper: S1 } | ||
|> SubCmd.finish({ name: "s1", description: "A first subcommand.", mapper: S1 }) | ||
|
||
subcommand_parser2 = | ||
Opt.maybe_u64 { short: "d", help: "This doesn't overlap with s1's -d flag." } | ||
|> Cli.map DFlag | ||
|> SubCmd.finish { | ||
Opt.maybe_u64({ short: "d", help: "This doesn't overlap with s1's -d flag." }) | ||
|> Cli.map(DFlag) | ||
|> SubCmd.finish({ | ||
name: "s2", | ||
description: "Another subcommand.", | ||
mapper: S2, | ||
} | ||
}) | ||
|
||
sub_subcommand_parser1 = | ||
{ Cli.weave <- | ||
a: Opt.u64 { short: "a", help: "An example short flag for a sub-subcommand." }, | ||
b: Opt.u64 { short: "b", help: "Another example short flag for a sub-subcommand." }, | ||
a: Opt.u64({ short: "a", help: "An example short flag for a sub-subcommand." }), | ||
b: Opt.u64({ short: "b", help: "Another example short flag for a sub-subcommand." }), | ||
} | ||
|> SubCmd.finish { name: "ss1", description: "A sub-subcommand.", mapper: SS1 } | ||
|> SubCmd.finish({ name: "ss1", description: "A sub-subcommand.", mapper: SS1 }) | ||
|
||
sub_subcommand_parser2 = | ||
{ Cli.weave <- | ||
a: Opt.u64 { short: "a", help: "Set the alpha level." }, | ||
c: Opt.u64 { short: "c", long: "create", help: "Create a doohickey." }, | ||
data: Param.str { name: "data", help: "Data to manipulate." }, | ||
a: Opt.u64({ short: "a", help: "Set the alpha level." }), | ||
c: Opt.u64({ short: "c", long: "create", help: "Create a doohickey." }), | ||
data: Param.str({ name: "data", help: "Data to manipulate." }), | ||
} | ||
|> SubCmd.finish { name: "ss2", description: "Another sub-subcommand.", mapper: SS2 } | ||
|> SubCmd.finish({ name: "ss2", description: "Another sub-subcommand.", mapper: SS2 }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.