Commit Graph

40 Commits

Author SHA1 Message Date
Alec Thomas ca0490fe2a Add some helper functions to the models. 2018-06-03 07:41:37 +10:00
Gerald Kaszuba 1426db8aa0 Added tag test for multiple separators. 2018-06-01 12:26:26 +10:00
Gerald Kaszuba 254fa00e81 Better name for parseCSV -> parseTagItems 2018-06-01 12:26:26 +10:00
Gerald Kaszuba ed123d1c06 Allow "bare" tags and moved tag tests into tag_test.go. Fixes #19 2018-06-01 12:26:26 +10:00
Alec Thomas fdc7230e22 Separate validation into a distinct step.
This allows help to be called even when the parse trace is invalid.
Without this, the command-line would have to be valid in order to use
help at all, which defeats the purpose.
2018-05-31 15:20:45 +10:00
Alec Thomas afbb431641 Convert Hook to an Option. 2018-05-31 15:20:45 +10:00
Alec Thomas cf89213e1e Add hook support. 2018-05-27 18:01:10 +10:00
Alec Thomas f60fe01f08 Move command/flag accumulation into ParseTrace. 2018-05-26 16:02:09 -04:00
Alec Thomas d20b44baf4 Remove a bunch of duplicate recover code. 2018-05-26 15:32:45 -04:00
Alec Thomas 0bb304449c Add Trace() function. 2018-05-26 10:04:10 -04:00
Gerald Kaszuba 93e21885b1 A basic refactor in build, splitting the two main code branches. 2018-05-26 00:28:47 -04:00
Alec Thomas 5df3b26bab Use new Tag type for slice separator. 2018-05-23 12:20:47 -04:00
Gerald Kaszuba 886edb6f5a Extend Tag for non-core decoders (Fixes #14) 2018-05-23 11:50:46 -04:00
Gerald Kaszuba 6c80dd3f31 README fix for the kong tag change 2018-05-23 09:33:58 +10:00
Gerald Kaszuba ecd369e622 Kong tag PR fixes (#12)
* Removed bubbling errors in favour of panic
* Added a test for Parse with a bad build and an arg.
* Removed is() function in favour of a switch with strings
* Collect key and value in parseCSV, reducing complexity.
* Fix in global to not use parser instance on error.
2018-05-22 09:18:08 -04:00
Alec Thomas 31e1ffaa3b Test for options. 2018-05-22 00:49:09 -04:00
Alec Thomas ab5cf7e6ef Tracing parser (#11)
* Add tracing to the parser.

* Synthesize a --help flag.

* Parsing now occurs in multiple phases.

1. Reset target.
2. Parse command-line into a "trace" (no values are written to target).
3. Apply traced, parsed values to the target fields.

This is another step in facilitating context-sensitive help and
completion.

* Detect duplicate flags.
2018-05-22 14:07:43 +10:00
Gerald Kaszuba 3eb5e285ed Use "kong" as tag keys fixes #9 (#10) 2018-05-21 09:25:19 -04:00
Alec Thomas 184735e689 Document how decoders work. 2018-05-20 00:42:54 +10:00
Alec Thomas 6a5fba0967 Move ParseContext into its own file. 2018-05-19 22:39:01 +10:00
Alec Thomas d7bb20f297 Factor out duplicate value reset code. 2018-05-19 22:15:14 +10:00
Alec Thomas d1acfab2e6 Factor parsing out into a ParseContext type.
This is groundwork for supporting context-sensitive help and completion.

Fixes #7.
2018-05-19 21:55:22 +10:00
Alec Thomas c27dd50be6 Move .Set = true into Decode(). 2018-05-19 21:04:23 +10:00
Gerald Kaszuba 8e96da517d Fixes #3 Required and optional flags+args (#6) 2018-05-19 20:54:26 +10:00
Alec Thomas aea859372c Switch to circleci. 2018-05-19 20:30:04 +10:00
Gerald Kaszuba a9179cd8ec Allow parent flags to be processed #4 2018-05-19 14:49:39 +10:00
Alec Thomas 3b21a54094 More validation. 2018-05-18 21:30:44 +10:00
Alec Thomas d03571a873 Use variadic options to configure Kong. 2018-05-18 21:17:48 +10:00
Gerald Kaszuba b4b5827044 Matching arg field (#1)
Check if the first field of an argument branch matches the parent struct field.
2018-05-18 18:38:53 +10:00
Alec Thomas 67b1a12059 Require cmd:"" or arg:"" for branching commands/args. 2018-05-18 15:39:40 +10:00
Alec Thomas a41bb0e4da Remove gotestyourself. 2018-05-18 14:41:10 +10:00
Alec Thomas c6776fe4b8 Docs. 2018-05-18 13:38:07 +10:00
Alec Thomas f929749094 Add Decode() method to Value to DRY. 2018-05-17 23:50:12 +10:00
Alec Thomas 31fe51f9d8 Support cumulative positional arguments. 2018-05-17 20:16:12 +10:00
Alec Thomas b9d002b746 Slice support. 2018-05-17 19:39:48 +10:00
Alec Thomas cb88963909 Clean up decoders a bit. 2018-05-17 11:21:20 +10:00
Alec Thomas 8f26b13088 Slice support. 2018-05-17 10:40:46 +10:00
Alec Thomas 1d00dfef7b Implemented most of the base parser.
This includes branching arguments as well as commands, eg.

    app user create <id> <first> <last>
    app user <id> delete
    app user <id> rename <to>

Of note, required/optional flags and positional arguments are not
currently enforced.
2018-05-16 20:33:18 +10:00
Alec Thomas 8516c68cc9 Add decoders scaffolding. 2018-04-10 21:17:00 +10:00
Alec Thomas aa1bf9dcb5 Initial commit. 2018-04-10 16:51:06 +10:00