2021-11-30 18:30:19 +00:00
*Jump to [source ](pacman.rs )*
[`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
pacman 5.2.1
Pacman Development Team
package manager utility
USAGE:
pacman[EXE] < SUBCOMMAND >
OPTIONS:
-h, --help Print help information
-V, --version Print version information
SUBCOMMANDS:
2022-02-14 22:20:33 +00:00
help Print this message or the help of the given subcommand(s)
query -Q --query Query the package database.
sync -S --sync Synchronize packages.
2022-02-14 17:51:01 +00:00
$ pacman -S -h
pacman[EXE]-sync
Synchronize packages.
USAGE:
2022-02-14 22:22:59 +00:00
pacman[EXE] {sync|--sync|-S} [OPTIONS] [--] [package]...
2022-02-14 17:51:01 +00:00
ARGS:
< package > ... packages
OPTIONS:
-h, --help Print help information
-i, --info view package information
-s, --search < search > ... search remote repositories for matching strings
```
And errors:
```console
$ pacman -S -s foo -i bar
? failed
error: The argument '--search < search > ...' cannot be used with '--info'
USAGE:
2022-02-14 22:22:59 +00:00
pacman[EXE] {sync|--sync|-S} --search < search > ... < package > ...
2022-02-14 17:51:01 +00:00
For more information try --help
```
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.