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
38pacman 5.2.1
39Pacman Development Team
40package manager utility
41
42USAGE:
43    pacman[EXE] <SUBCOMMAND>
44
45OPTIONS:
46    -h, --help       Print help information
47    -V, --version    Print version information
48
49SUBCOMMANDS:
50    help                Print this message or the help of the given subcommand(s)
51    query -Q --query    Query the package database.
52    sync -S --sync      Synchronize packages.
53
54$ pacman -S -h
55pacman[EXE]-sync
56Synchronize packages.
57
58USAGE:
59    pacman[EXE] {sync|--sync|-S} [OPTIONS] [--] [package]...
60
61ARGS:
62    <package>...    packages
63
64OPTIONS:
65    -h, --help                  Print help information
66    -i, --info                  view package information
67    -s, --search <search>...    search remote repositories for matching strings
68
69```
70
71And errors:
72```console
73$ pacman -S -s foo -i bar
74? failed
75error: The argument '--search <search>...' cannot be used with '--info'
76
77USAGE:
78    pacman[EXE] {sync|--sync|-S} --search <search>... <package>...
79
80For more information try --help
81
82```
83
84**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.
85Let's make a quick program to illustrate.
86