Closed Thesola10 closed 7 years ago
In principle that works as you suggested, however the option consisting of just a dash (-
) isn't supported.
Ok, if I have time I will have a look at how to implement that.
Le lun. 27 mars 2017 à 20:00, Sebastian Freundt notifications@github.com a écrit :
In principle that works as you suggested, however the option consisting of just a dash (-) isn't supported.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hroptatyr/yuck/issues/11#issuecomment-289357124, or mute the thread https://github.com/notifications/unsubscribe-auth/AG8x5NGU_eqL4rXUza2cg9hxwuBLwgNvks5rp0jngaJpZM4MpaNI .
Well, to be fair it's not hard to implement, the problem is that the single dash is often used to denote stdin or stdout and used as a positional argument. For instance: join FILE -
. The thing about dash options is that they're non-positional, i.e. it doesn't matter if -s
comes before -v
or after. And then there's the thing that single char options can be agglutinated, like -sv
to mean -s -v
, the single dash doesn't fit in here either.
To be honest it took me a while to understand how you mean it: cz copy FILE foo 400 -
would not modify file but instead reproduce the modification on stdout, right?
Why don't you do it sed style and reproduce the modifications on stdout by default with a -i|--in-place
option to make the operation destructive. If you look at Unix-ish tools, none of them are destructive by default, thankfully, I rarely get a call to sed right in the first place which would leave me with a bogus file had sed chosen to operate destructively by default.
On the other hand I'm not here to tell you how to do your job, so here's another suggestion that doesn't interfere with current yuck: Use the -
as a positional argument, something like:
yuck_parse(argi, argc, argv);
...
for (size_t i = 0; i < argi->nargs; i++) {
if (!strcmp(argi->args[i], "-") {
/* There's been a - argument on the command line */
...
}
}
And then turn the line with the dash into a comment like so:
Usage: cz copy [FILE] [SECTION] [LINE] [OPTION]... [-]
Copy a section to a target line number. Use final - to not modify the file, but to write to stdout instead.
It's just a suggestion.
What I mean is, can I make it so regular options can be applied to several commands such as verbose/silent and stdout. Stdout does not have to be a single dash.
Le mar. 28 mars 2017 à 05:27, Sebastian Freundt notifications@github.com a écrit :
Well, to be fair it's not hard to implement, the problem is that the single dash is often used to denote stdin or stdout and used as a positional argument. For instance: join FILE -. The thing about dash options is that they're non-positional, i.e. it doesn't matter if -s comes before -v or after. And then there's the thing that single char options can be agglutinated, like -sv to mean -s -v, the single dash doesn't fit in here either.
To be honest it took me a while to understand how you mean it: cz copy FILE foo 400 - would not modify file but instead reproduce the modification on stdout, right?
Why don't you do it sed style and reproduce the modifications on stdout by default with a -i|--in-place option to make the operation destructive. If you look at Unix-ish tools, none of them are destructive by default, thankfully, I rarely get a call to sed right in the first place which would leave me with a bogus file had sed chosen to operate destructively by default.
On the other hand I'm not here to tell you how to do your job, so here's another suggestion that doesn't interfere with current yuck: Use the - as a positional argument, something like:
yuck_parse(argi, argc, argv); ... for (size_t i = 0; i < argi->nargs; i++) { if (!strcmp(argi->args[i], "-") { / There's been a - argument on the command line / ... } }
And then turn the line with the dash into a comment like so:
Usage: cz copy [FILE] [SECTION] [LINE] [OPTION]... [-] Copy a section to a target line number. Use final - to not modify the file, but to write to stdout instead.
It's just a suggestion.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hroptatyr/yuck/issues/11#issuecomment-289652228, or mute the thread https://github.com/notifications/unsubscribe-auth/AG8x5HC8sC0iYtgPRd-CfWRfrZDE1bdRks5rqH4dgaJpZM4MpaNI .
Yes, that's the default already. If you have a general Usage:
line with no subcommands, all options there can be applied to all subcommands.
Okay I see
Hello, I would like to be able to define options that would apply to all commands, just like
--help
and--version
. Here is my current YUCK fileI would like options
-
,--verbose
and--silent
to apply on any subcommand.