• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[`pacman`](https://wiki.archlinux.org/index.php/pacman) defines subcommands via flags.
2
3Here, `-S` is a short flag subcommand:
4```console
5$ pacman -S package
6Installing package...
7
8```
9
10Here `--sync` is a long flag subcommand:
11```console
12$ pacman --sync package
13Installing package...
14
15```
16
17Now the short flag subcommand (`-S`) with a long flag:
18```console
19$ pacman -S --search name
20Searching for name...
21
22```
23
24And the various forms of short flags that work:
25```console
26$ pacman -S -s name
27Searching for name...
28
29$ pacman -Ss name
30Searching for name...
31
32```
33*(users can "stack" short subcommands with short flags or with other short flag subcommands)*
34
35In the help, this looks like:
36```console
37$ pacman -h
38package manager utility
39
40Usage: pacman[EXE] <COMMAND>
41
42Commands:
43  query, -Q, --query  Query the package database.
44  sync, -S, --sync    Synchronize packages.
45  help                Print this message or the help of the given subcommand(s)
46
47Options:
48  -h, --help     Print help
49  -V, --version  Print version
50
51$ pacman -S -h
52Synchronize packages.
53
54Usage: pacman[EXE] {sync|--sync|-S} [OPTIONS] [package]...
55
56Arguments:
57  [package]...  packages
58
59Options:
60  -s, --search <search>...  search remote repositories for matching strings
61  -i, --info                view package information
62  -h, --help                Print help
63
64```
65
66And errors:
67```console
68$ pacman -S -s foo -i bar
69? failed
70error: the argument '--search <search>...' cannot be used with '--info'
71
72Usage: pacman[EXE] {sync|--sync|-S} --search <search>... <package>...
73
74For more information, try '--help'.
75
76```
77
78**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.
79Let's make a quick program to illustrate.
80