Added shfmt
[webi-installers/.git] / shfmt / README.md
1 ---
2 title: shfmt
3 homepage: https://github.com/mvdan/sh
4 tagline: |
5   shfmt: Format shell programs
6 ---
7
8 To update or switch versions, run `webi shfmt@stable` or `webi shfmt@beta`, etc.
9
10 # Cheat Sheet
11
12 > shfmt is a shell parser, formatter and interpretter that supports POSIX Shell, Bash and mksh.
13
14 Usage: `shfmt <flags> <filepath>`
15
16 Note: If given path is directory, all shell scripts in the directory will be used. 
17
18 ## Flags:
19
20 *-version*
21         Show version and exit.
22
23 *-l*
24         List files whose formatting differs from shfmt's.
25
26 *-w*
27         Write result to file instead of stdout.
28
29 *-d*
30         Error with a diff when the formatting differs.
31
32 *-s*
33         Simplify the code.
34
35 *-mn*
36         Minify the code to reduce its size (implies -s).
37
38 *-ln* <str>
39         Language variant to parse (bash/posix/mksh/bats, default "bash").
40
41 *-p*
42         Shorthand for -ln=posix.
43
44 *-filename* str
45         Provide a name for the standard input file.
46
47 *-i* <uint>
48         Indent: 0 for tabs (default), >0 for number of spaces.
49
50 *-bn*
51         Binary ops like && and | may start a line.
52
53 *-ci*
54         Switch cases will be indented.
55
56 *-sr*
57         Redirect operators will be followed by a space.
58
59 *-kp*
60         Keep column alignment paddings.
61
62 *-fn*
63         Function opening braces are placed on a separate line.
64
65 *-f*
66         Recursively find all shell files and print the paths.
67
68 *-tojson*
69         Print syntax tree to stdout as a typed JSON.
70
71 See https://github.com/mvdan/sh for more info.