-
-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI package update 1 #2019
CLI package update 1 #2019
Conversation
This should have a CHANGELOG entry (or entries) for features added. Can you do a short writeup of the changes and how they should be in release notes when this goes out? I don't think anyone but you is capabale of writing up those notes @cquinn. It would be good to get them recorded now. |
packages/cli/_test.pony
Outdated
else | ||
return // error was expected | ||
let cs = CommandSpec.leaf("min imal", "") | ||
h.fail("expected error on bad command name" + cs.name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to append :
to your string literal here.
Otherwise the cs.name()
bit is going to get printed squished up against the word "name" from the string literal when printed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
@@ -325,22 +343,66 @@ class val ArgSpec | |||
_name + "[" + _typ.string() + "]" + | |||
if not _required then "(=" + _default.string() + ")" else "" end | |||
|
|||
type _Value is (Bool | String | I64 | F64) | |||
class _StringSeq is ReadSeq[String] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a persistent data structure holding a sequence of strings. Have you thought about using Vec[String]
from the collections/persistent
package instead of rolling your own here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me give that a look. I started with this simple wrapper class to get a Stringable and a String sequence of some kind. But a persistent structure might make more sense given the way it has to be updated during parse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I still need the wrapper class, but could replace the Array[String] with a Vec[String] to avoid the array copying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
packages/cli/command_spec.pony
Outdated
ss.append(ss1.strings) | ||
strings = ss | ||
|
||
fun string(): String => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're aiming to fulfill the Stringable
interface, this should be returning a String iso^
, which should be possible if you remove the trn
from your recover
statement below (so that it recovers to iso
instead).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
packages/cli/command_spec.pony
Outdated
if str.size() > 1 then str.append(",") end | ||
str.append(s) | ||
end | ||
str.append("]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For each of these append
calls where you're appending a single-character string, you could be push
ing just the single character (as a U8
) instead. For example: str.push(']')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
@SeanTAllen I can certainly write up CHANGELOG entries. Can you point me to an example I can refer to? |
Check out the existing CHANGELOG entries. I'd say this PR is multiple entries. |
@SeanTAllen I guess I/we never wrote up changelog entries for the CLI package at all. I can take a stab at that too. Should I just add an edit to CHANGELOG.md in this PR? |
Yes to CHANGELOG entries being part of this PR |
503db79
to
1aa3933
Compare
I've added a CHANGELOG entry to the unreleased section for the whole CLI implementation in this and the initial PR. |
@cquinn - I don't fully understand the semantics of the |
@jemc yes, I will take some time now to document the types and the package as a whole, and add that to this PR. |
…lname. Checking commands are leaves.
…ests. Fixed bug where unknown short options were missed.
8e10426
to
67c1403
Compare
@jemc @SeanTAllen I have added more doc comments, and a big CHANELOG entry. I'm not sure if the CHANGELOG entry is too much and maybe I should pare it down. |
Thanks for the extra docs, it's great! Maybe I'm being obtuse, but I still don't really understand what the CLI args for a "string seq" are supposed to look like, though... 😕 |
@cquinn changelog looks good to me. |
@jemc I've added more doc comments. The idea behind a string_seq is that it is a repeated option or arg that produces a sequence of strings after parsing. It can be used, for example, to allow multiple filenames to be passed to a tool that read them. The |
If I have an |
With Maybe I need to include this doc somewhere as a comment. |
Got it. It makes sense now. Yes, I'd definitely like to see that in the documentation, since I don't think I'm the only one who will have that question 👍. |
@jemc How does it look now? |
Great, thanks. |
Features added:
Other changes: