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

DOCS/man: replace legacy option syntax usage #14099

Merged
merged 1 commit into from
May 24, 2024

Conversation

na-na-hi
Copy link
Contributor

@na-na-hi na-na-hi commented May 9, 2024

They are replaced by --option=value.

@kasper93
Copy link
Contributor

kasper93 commented May 9, 2024

Why? How --v is better than -v?

DOCS/man/options.rst Outdated Show resolved Hide resolved
@sfan5
Copy link
Member

sfan5 commented May 9, 2024

The "Legacy option syntax" section (here) only talks about -option value, not -flag.
While I value consistency I think the single letter flags are an exception and -v -v is much more aesthetically pleasing than --v --v

@na-na-hi
Copy link
Contributor Author

na-na-hi commented May 9, 2024

The "Legacy option syntax" section (here) only talks about -option value, not -flag.

Flag options are normal options which take values in essence: they're equivalent to --flag=yes. In fact most flag options are already documented as --flag=<yes|no>.

Since they are no different from options which take values, this description in the documentation also takes effect on flag options, which says such usage should be avoided:

This is mostly for compatibility with MPlayer. Using these should be avoided. Their semantics can change any time in the future.

@kasper93
Copy link
Contributor

kasper93 commented May 9, 2024

Single letter flags (like -v) should use single dash. We can even make it into documentation or restrict it in the code. I agree longer flags should use --.

I strongly disagree on making --v standard and recommended use.

@Dudemanguy
Copy link
Member

Single letter flags are pretty standard across any program. If you find the wording of the legacy option section in the documentation too ambiguous, I would suggest rewording that instead.

@na-na-hi
Copy link
Contributor Author

na-na-hi commented May 9, 2024

Single letter flags (like -v) should use single dash. We can even make it into documentation or restrict it in the code.

MPlayer uses single dash for all options, while mpv prefers double dash. Treating single letter flags differently has no ground in MPlayer/mpv convention and history. Besides, these options already accept double dashes, so restricting it in the code creates backwards incompatibility.

Also what about non flag single-letter options like --o? Should it use single or double dash? Treating them differently only causes confusion.

I strongly disagree on making --v standard and recommended use.

I can make an explicit exception for that and document it. Is this good enough for you?

@kasper93
Copy link
Contributor

kasper93 commented May 9, 2024

MPlayer uses single dash for all options, while mpv prefers double dash. Treating single letter flags differently has no ground in MPlayer/mpv convention and history.

We are not in the void. Single letter flags are common like @Dudemanguy said. --verbose, -v is one of the common way to do it.

so restricting it in the code creates backwards incompatibility.

Of course, we cannot introduce breaking change like that. But we should not recommend that either imho. I would go even further and add depreciation warning about inconsistent use of - and --.

I can make an explicit exception for that and document it. Is this good enough for you?

No need for explicit exception. I think we should make it clear that all single-letter flags should be prefixed with single-dash - and all longer options should be prefixed with double-dash --. Maybe I'm missing some context, but it is obvious to me and frankly I wasn't aware we can do --v up until now.

Either way, I don't mind as long as -v still works.

They are replaced by --option=value.
@na-na-hi
Copy link
Contributor Author

na-na-hi commented May 9, 2024

Reverted the --v change.

I think we should make it clear that all single-letter flags should be prefixed with single-dash - and all longer options should be prefixed with double-dash --.

I don't think such preference is necessary.

Maybe I'm missing some context, but it is obvious to me and frankly I wasn't aware we can do --v up until now.

This has been already used in the documentation, dating back to 2014:

``--v`` option, and is also what is used for ``--msg-level``.

in verbose mode, i.e. ``--v``. In general we can't print errors, because

of ``--v`` options passed to the command line.

@N-R-K
Copy link
Contributor

N-R-K commented May 10, 2024

I don't think such preference is necessary.

It's not a preference. It's the de facto standard.

@na-na-hi
Copy link
Contributor Author

na-na-hi commented May 10, 2024

It's the de facto standard.

Doesn't matter. FFmpeg and gcc for example use single dash for long options, which doesn't conform to the "standard". There is no obligation for mpv to use single dash for single-letter options either. In all situations mentioned, the history and convention of individual programs take preference over everything else.

See b85983a for example: this commit from 2014 explicitly changes the --o documentation to use the new double dash syntax, despite being a single letter option. This clearly shows that the double dash syntax is the preferred style for most of the documentation since the beginning of the history of mpv.

@N-R-K
Copy link
Contributor

N-R-K commented May 10, 2024

FFmpeg and gcc for example use single dash for long options, which doesn't conform to the "standard".

I wasn't talking about long options, which don't have any standard (neither POSIX nor de facto). Some programs use double dash some use single.

But short options are very widely supported and expected with a single dash. So far I haven't seen any actual reason to document a syntax that's both unconventional and worse to type.

[...] since the beginning of the history of mpv

Arbitrary choices made in the past without any actual reasoning behind it isn't really a convincing argument.

There's a 1k line document in this repo documenting all the interface changes each release. If "it was done this way before" was a valid argument by itself then you wouldn't be able to change anything at all aside from fixing bugs.

@na-na-hi
Copy link
Contributor Author

na-na-hi commented May 10, 2024

I wasn't talking about long options, which don't have any standard (neither POSIX nor de facto).

The GNU getopt_long is the de facto standard, and most independent commandline parsers for other languages follow the same semantics. getopt_long doesn't require that long options are longer than a single letter; in fact, its documentation explicitly says that programs don't need to support short options at all.

But short options are very widely supported and expected with a single dash.

The reality says otherwise. Lots of GNU coreutils don't implement -h at all: it doesn't even do anything. Instead, they demand you to type --help. So here is your "convention": utilities have no obligation to make the commandline easier to type.

Arbitrary choices made in the past without any actual reasoning behind it isn't really a convincing argument.

So are arbitrary standards. If we strictly follow the POSIX standard and convention, we can't have long options at all.

If "it was done this way before" was a valid argument by itself then you wouldn't be able to change anything at all aside from fixing bugs.

I wanted to make --v the preferred way (which is a change from the current option documentation) but lots of comments rejected the --v change for the same reason.

@Dudemanguy Dudemanguy merged commit 43136b6 into mpv-player:master May 24, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

None yet

5 participants