2021-11-30 18:30:19 +00:00
[`pacman` ](https://wiki.archlinux.org/index.php/pacman ) defines subcommands via flags.
2021-11-10 22:15:30 +00:00
Here, `-S` is a short flag subcommand:
2022-01-05 16:54:33 +00:00
```console
2021-11-30 18:30:19 +00:00
$ pacman -S package
2021-11-10 22:15:30 +00:00
Installing package...
2022-01-05 16:54:33 +00:00
2021-11-10 22:15:30 +00:00
```
Here `--sync` is a long flag subcommand:
2022-01-05 16:54:33 +00:00
```console
2021-11-30 18:30:19 +00:00
$ pacman --sync package
2021-11-10 22:15:30 +00:00
Installing package...
2022-01-05 16:54:33 +00:00
2021-11-10 22:15:30 +00:00
```
Now the short flag subcommand (`-S`) with a long flag:
2022-01-05 16:54:33 +00:00
```console
2021-11-30 18:30:19 +00:00
$ pacman -S --search name
2021-11-10 22:15:30 +00:00
Searching for name...
2022-01-05 16:54:33 +00:00
2021-11-10 22:15:30 +00:00
```
And the various forms of short flags that work:
2022-01-05 16:54:33 +00:00
```console
2021-11-30 18:30:19 +00:00
$ pacman -S -s name
2021-11-10 22:15:30 +00:00
Searching for name...
2022-01-05 16:54:33 +00:00
2021-11-30 18:30:19 +00:00
$ pacman -Ss name
2021-11-10 22:15:30 +00:00
Searching for name...
2022-01-05 16:54:33 +00:00
2021-11-10 22:15:30 +00:00
```
*(users can "stack" short subcommands with short flags or with other short flag subcommands)*
2022-02-14 17:51:01 +00:00
In the help, this looks like:
```console
$ pacman -h
package manager utility
2022-09-07 16:03:55 +00:00
Usage: pacman[EXE] < COMMAND >
2022-02-14 17:51:01 +00:00
2022-08-31 02:38:37 +00:00
Commands:
2022-09-19 14:07:37 +00:00
query, -Q, --query Query the package database.
sync, -S, --sync Synchronize packages.
help Print this message or the help of the given subcommand(s)
2022-02-14 17:51:01 +00:00
2022-08-26 15:59:27 +00:00
Options:
2023-01-03 16:49:43 +00:00
-h, --help Print help
-V, --version Print version
2022-08-26 15:59:27 +00:00
2022-02-14 17:51:01 +00:00
$ pacman -S -h
Synchronize packages.
2022-09-07 16:03:55 +00:00
Usage: pacman[EXE] {sync|--sync|-S} [OPTIONS] [package]...
2022-02-14 17:51:01 +00:00
2022-08-26 14:40:23 +00:00
Arguments:
2022-09-07 20:29:15 +00:00
[package]... packages
2022-02-14 17:51:01 +00:00
2022-08-26 14:40:23 +00:00
Options:
2022-09-07 20:29:15 +00:00
-s, --search < search > ... search remote repositories for matching strings
-i, --info view package information
2023-01-03 16:49:43 +00:00
-h, --help Print help
2022-02-14 17:51:01 +00:00
```
And errors:
```console
$ pacman -S -s foo -i bar
? failed
2023-01-03 16:22:40 +00:00
error: the argument '--search < search > ...' cannot be used with '--info'
2022-02-14 17:51:01 +00:00
2022-09-07 16:03:55 +00:00
Usage: pacman[EXE] {sync|--sync|-S} --search < search > ... < package > ...
2022-02-14 17:51:01 +00:00
2023-01-03 19:22:35 +00:00
For more information, try '--help'.
2022-02-14 17:51:01 +00:00
```
2021-11-10 22:15:30 +00:00
**NOTE:** Keep in mind that subcommands, flags, and long flags are *case sensitive* : `-Q` and `-q` are different flags/subcommands. For example, you can have both `-Q` subcommand and `-q` flag, and they will be properly disambiguated.
Let's make a quick program to illustrate.