Skip to content
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

Comments in args file #57

Open
alensiljak opened this issue May 16, 2019 · 5 comments
Open

Comments in args file #57

alensiljak opened this issue May 16, 2019 · 5 comments

Comments

@alensiljak
Copy link

Please note that I am not too familiar with cmdargs but am a user of hledger, which uses cmdargs for parsing arguments stored in text files.
As specified in an issue there, I find that it would be very convenient to have comments in the argument files.
In case the functionality of reading the argument files is indeed part of cmdargs, would you consider ignoring lines that start with ";" (or other delimiters), for example, and leave them as comments.
This might be really useful for cases when there are multiple or confusing arguments, or just temporarily removing some of them.
Thanks!

@ndmitchell
Copy link
Owner

Seems a reasonable thing to do - only question is what should the comment syntax be? Can you find any other similar args files that use comments? I'd prefer to copy rather than do something different.

@alensiljak
Copy link
Author

alensiljak commented May 27, 2019

Hi! Thanks a lot for the feedback. I'm coming from the viewpoint of parsing the arguments for ledger-style argument files, also used in hledger.
Ledger supports the following characters for comments: https://www.ledger-cli.org/3.0/doc/ledger3.html#Commenting-on-your-Journal

Naturally, I would not expect cmdargs to follow ledger's specs but some of those are common comment chars, like # and ;. Perhaps others, too, but I'm mostly using these two. That might be a good start?

Edit: Technically, arguments start with -- or / or a letter [A-z][a-z] or a number [0-9]? So, in theory, any other special character might a comment. But that would be too restrictive.

@simonmichael
Copy link

Count me interested too. The recent https://www.stevegattuso.me/tech-stack/finances-budgeting.html#args has some nice examples of args files commented with #, but I'm not sure this actually works - it doesn't for me.

The only docs I have found for the argument file format are at https://stackoverflow.com/questions/53995002/where-does-shell-argument-files-or-files-originate-from .

@bsima
Copy link

bsima commented Nov 17, 2022

The recent https://www.stevegattuso.me/tech-stack/finances-budgeting.html#args has some nice examples of args files commented with #, but I'm not sure this actually works - it doesn't for me.

Presumably this was just an annotated example and the # comments aren't actually part of the files

@simonmichael
Copy link

The implementation is here: https://github.com/ndmitchell/cmdargs/blob/master/System/Console/CmdArgs/Explicit/ExpandArgsAt.hs#L7

Ignoring lines beginning with # or whitespace and # would be easy. Correctly ignoring end-of-line # comments is harder, it would be nice not to break quoted arguments containing #. Or you could ignore shell quoting rules, as I suspect java does (https://docs.oracle.com/javase/9/tools/java.htm#JSWOR-GUID-4856361B-8BFD-4964-AE84-121F5F6CF111 : Use the number sign # in the argument file to identify comments. All characters following the# are ignored until the end of line.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants