argparse icon indicating copy to clipboard operation
argparse copied to clipboard

[Feature Request]: reverse formatting of given table back into command line args

Open Shelim opened this issue 4 years ago • 0 comments

First of all - thank you for this tool and your awesome work on it.

I wonder if there is a possibility to do reverse formatting (parsing) of given table back into command line args using the same parser definition. I could not find that information in tutorial nor docs, so I assume it is unimplemented now. If I am mistaken, please point me in the right direction.

If it is indeed not implemented, I can work on some PR myself

The feature itself - for example if given:

local parser = argparse("script", "An example.")
parser:argument("input", "Input file.")
parser:option("-o --output", "Output file.", "a.out")
parser:option("-I --include", "Include locations."):count("*")

And:

{
   input = "foo",
   output = "bar",
   include = {"/usr/local/include", "src"}
}

It should produce the (possibly customizable) result of:

foo -o bar -I/usr/local/include -Isrc

Usage case:

System Administrator may use interactive Lua shell script to construct complex command to be executed. After they are done with setting all parameters they might be presented with non-interactive command line equivalent query to be used next time instead of going through the complicated script wizard again.

Shelim avatar Apr 02 '21 00:04 Shelim