docopt icon indicating copy to clipboard operation
docopt copied to clipboard

Feature Request: Support for @FILE CLI Option for Additional CLI Options

Open calebwherry opened this issue 10 years ago • 10 comments

I created a StackOverflow question and got no hits on it. I also have looked through all the documentation and can't find anything on it so I am putting in a feature request.

In some command line applications, there is the ability to use the @FILE syntax to include a file that contains more CLI options. This is especially useful for apps like ar when you could potentially run into the max length of a command line call.

I use DocOpt.cpp so I would most likely port this over to that if it gets approved. I wanted to post it here to get people's feedback on if it is something everyone agrees is a good addition to DocOpt.

calebwherry avatar Dec 16 '14 16:12 calebwherry

I could not find anything about @ syntax in ar man page. Docopt only supports widely-used conventions. If you can provide many more examples of programs using this convention I will look into it.

I suggest you to use an option instead, e.g. -@, or even better --config-file=<file>.

keleshev avatar Dec 16 '14 16:12 keleshev

The page you linked to seems to be a fairly out of date man page for ar. From http://man7.org/linux/man-pages/man1/ar.1.html:

@file Read command-line options from file. The options read are inserted in place of the original @file option. If file does not exist, or cannot be read, then the option will be treated literally, and not removed.

     Options in file are separated by whitespace.  A whitespace character may be included in an option by surrounding the entire option in either single or double quotes.
     Any character (including a backslash) may be included by prefixing the character to be included with a backslash.  The file may itself contain additional @file options;
     any such options will be processed recursively.

calebwherry avatar Dec 16 '14 17:12 calebwherry

In fact, the entire gcc toolchain accepts that as an argument now. On my system (Debian Wheezy 64-bit with binutils-2.21.90), searching through all the man pages yields this list that supports it:

gcc addr2line ar AS c++filt dlltool elfedit ld nlmconv nm objcopy objdump ranlib readelf size strings strip troff windmc mandb

Not sure this should have been closed so quickly, especially with outdated manpage information.

calebwherry avatar Dec 16 '14 17:12 calebwherry

And just to add, your suggestions of -@, or even better --config-file=<file> go against the main point of this new CLI option. The point is to have the CLI options in the file get parsed along with all the CLI options, not to have them parsed after the initial CLI parsing. If they were processed afterwards, then you could not supply things like mutually exclusive options in the file and have docopt deal with them, you would have to do it manually afterwards. Not a solution by any means because then I'm just writing my own parser for everything in the @file.

calebwherry avatar Dec 16 '14 17:12 calebwherry

@docopt/docopt, what do you think?

keleshev avatar Dec 16 '14 20:12 keleshev

It seems like a pretty niche feature, but it seems like its addition would have little affect on the complexity of existing Docopt implementations. So I wouldn't strongly oppose it.

BurntSushi avatar Dec 16 '14 22:12 BurntSushi

+1 It should improve the usability and the probability to disrupt the compatibility would be small. Also, adding this feature is fairly easy. I have no reason to reject it.

bicycle1885 avatar Dec 16 '14 23:12 bicycle1885

+1

On 16 December 2014 at 23:16, Kenta Sato (佐藤 建太) [email protected] wrote:

+1 It should improve the usability and the probability to disrupt the compatibility would be small. Also, adding this feature is fairly easy. I have no reason to reject it.

— Reply to this email directly or view it on GitHub https://github.com/docopt/docopt/issues/242#issuecomment-67251062.

voieducode avatar Dec 19 '14 22:12 voieducode

I would also like to have some support for reading flags from file like gflags. Any syntax is most likely ok

ptman avatar Feb 19 '16 12:02 ptman

Any updates on this issue? FWIW it also matches the argparse fromfile_prefix_chars option and might be the only thing stopping us from switching over our argparse-heavy utility to using docopt

thejcannon avatar Apr 02 '19 19:04 thejcannon