• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

_examples/H17-Dec-2017-

cmd/genvalues/H17-Dec-2017-

.travis.ymlH A D17-Dec-201761

COPYINGH A D17-Dec-20171 KiB

README.mdH A D17-Dec-201721.9 KiB

actions.goH A D17-Dec-2017959

app.goH A D17-Dec-201718.3 KiB

app_test.goH A D17-Dec-201710.9 KiB

args.goH A D17-Dec-20174 KiB

args_test.goH A D17-Dec-20172.1 KiB

cmd.goH A D17-Dec-20176.4 KiB

cmd_test.goH A D17-Dec-201711 KiB

completions.goH A D17-Dec-2017903

completions_test.goH A D17-Dec-20171.7 KiB

doc.goH A D17-Dec-20172 KiB

envar.goH A D17-Dec-2017889

examples_test.goH A D17-Dec-20171.1 KiB

flags.goH A D17-Dec-20177.2 KiB

flags_test.goH A D17-Dec-20179.3 KiB

global.goH A D17-Dec-20172.7 KiB

guesswidth.goH A D17-Dec-2017151

guesswidth_unix.goH A D17-Dec-2017728

model.goH A D17-Dec-20174.3 KiB

parser.goH A D17-Dec-20178.7 KiB

parser_test.goH A D17-Dec-20173.1 KiB

parsers.goH A D17-Dec-20175.3 KiB

parsers_test.goH A D17-Dec-20172 KiB

templates.goH A D17-Dec-20176.8 KiB

usage.goH A D17-Dec-20175.4 KiB

usage_test.goH A D17-Dec-20171.5 KiB

values.goH A D17-Dec-20179.9 KiB

values.jsonH A D17-Dec-20171.7 KiB

values_generated.goH A D17-Dec-201718.4 KiB

values_test.goH A D17-Dec-20172.4 KiB

README.md

1# Kingpin - A Go (golang) command line and flag parser
2[![](https://godoc.org/github.com/alecthomas/kingpin?status.svg)](http://godoc.org/github.com/alecthomas/kingpin) [![Build Status](https://travis-ci.org/alecthomas/kingpin.svg?branch=master)](https://travis-ci.org/alecthomas/kingpin) [![Gitter chat](https://badges.gitter.im/alecthomas.png)](https://gitter.im/alecthomas/Lobby)
3
4
5
6<!-- MarkdownTOC -->
7
8- [Overview](#overview)
9- [Features](#features)
10- [User-visible changes between v1 and v2](#user-visible-changes-between-v1-and-v2)
11  - [Flags can be used at any point after their definition.](#flags-can-be-used-at-any-point-after-their-definition)
12  - [Short flags can be combined with their parameters](#short-flags-can-be-combined-with-their-parameters)
13- [API changes between v1 and v2](#api-changes-between-v1-and-v2)
14- [Versions](#versions)
15  - [V2 is the current stable version](#v2-is-the-current-stable-version)
16  - [V1 is the OLD stable version](#v1-is-the-old-stable-version)
17- [Change History](#change-history)
18- [Examples](#examples)
19  - [Simple Example](#simple-example)
20  - [Complex Example](#complex-example)
21- [Reference Documentation](#reference-documentation)
22  - [Displaying errors and usage information](#displaying-errors-and-usage-information)
23  - [Sub-commands](#sub-commands)
24  - [Custom Parsers](#custom-parsers)
25  - [Repeatable flags](#repeatable-flags)
26  - [Boolean Values](#boolean-values)
27  - [Default Values](#default-values)
28  - [Place-holders in Help](#place-holders-in-help)
29  - [Consuming all remaining arguments](#consuming-all-remaining-arguments)
30  - [Bash/ZSH Shell Completion](#bashzsh-shell-completion)
31  - [Supporting -h for help](#supporting--h-for-help)
32  - [Custom help](#custom-help)
33
34<!-- /MarkdownTOC -->
35
36## Overview
37
38Kingpin is a [fluent-style](http://en.wikipedia.org/wiki/Fluent_interface),
39type-safe command-line parser. It supports flags, nested commands, and
40positional arguments.
41
42Install it with:
43
44    $ go get gopkg.in/alecthomas/kingpin.v2
45
46It looks like this:
47
48```go
49var (
50  verbose = kingpin.Flag("verbose", "Verbose mode.").Short('v').Bool()
51  name    = kingpin.Arg("name", "Name of user.").Required().String()
52)
53
54func main() {
55  kingpin.Parse()
56  fmt.Printf("%v, %s\n", *verbose, *name)
57}
58```
59
60More [examples](https://github.com/alecthomas/kingpin/tree/master/_examples) are available.
61
62Second to parsing, providing the user with useful help is probably the most
63important thing a command-line parser does. Kingpin tries to provide detailed
64contextual help if `--help` is encountered at any point in the command line
65(excluding after `--`).
66
67## Features
68
69- Help output that isn't as ugly as sin.
70- Fully [customisable help](#custom-help), via Go templates.
71- Parsed, type-safe flags (`kingpin.Flag("f", "help").Int()`)
72- Parsed, type-safe positional arguments (`kingpin.Arg("a", "help").Int()`).
73- Parsed, type-safe, arbitrarily deep commands (`kingpin.Command("c", "help")`).
74- Support for required flags and required positional arguments (`kingpin.Flag("f", "").Required().Int()`).
75- Support for arbitrarily nested default commands (`command.Default()`).
76- Callbacks per command, flag and argument (`kingpin.Command("c", "").Action(myAction)`).
77- POSIX-style short flag combining (`-a -b` -> `-ab`).
78- Short-flag+parameter combining (`-a parm` -> `-aparm`).
79- Read command-line from files (`@<file>`).
80- Automatically generate man pages (`--help-man`).
81
82## User-visible changes between v1 and v2
83
84### Flags can be used at any point after their definition.
85
86Flags can be specified at any point after their definition, not just
87*immediately after their associated command*. From the chat example below, the
88following used to be required:
89
90```
91$ chat --server=chat.server.com:8080 post --image=~/Downloads/owls.jpg pics
92```
93
94But the following will now work:
95
96```
97$ chat post --server=chat.server.com:8080 --image=~/Downloads/owls.jpg pics
98```
99
100### Short flags can be combined with their parameters
101
102Previously, if a short flag was used, any argument to that flag would have to
103be separated by a space. That is no longer the case.
104
105## API changes between v1 and v2
106
107- `ParseWithFileExpansion()` is gone. The new parser directly supports expanding `@<file>`.
108- Added `FatalUsage()` and `FatalUsageContext()` for displaying an error + usage and terminating.
109- `Dispatch()` renamed to `Action()`.
110- Added `ParseContext()` for parsing a command line into its intermediate context form without executing.
111- Added `Terminate()` function to override the termination function.
112- Added `UsageForContextWithTemplate()` for printing usage via a custom template.
113- Added `UsageTemplate()` for overriding the default template to use. Two templates are included:
114    1. `DefaultUsageTemplate` - default template.
115    2. `CompactUsageTemplate` - compact command template for larger applications.
116
117## Versions
118
119Kingpin uses [gopkg.in](https://gopkg.in/alecthomas/kingpin) for versioning.
120
121The current stable version is [gopkg.in/alecthomas/kingpin.v2](https://gopkg.in/alecthomas/kingpin.v2). The previous version, [gopkg.in/alecthomas/kingpin.v1](https://gopkg.in/alecthomas/kingpin.v1), is deprecated and in maintenance mode.
122
123### [V2](https://gopkg.in/alecthomas/kingpin.v2) is the current stable version
124
125Installation:
126
127```sh
128$ go get gopkg.in/alecthomas/kingpin.v2
129```
130
131### [V1](https://gopkg.in/alecthomas/kingpin.v1) is the OLD stable version
132
133Installation:
134
135```sh
136$ go get gopkg.in/alecthomas/kingpin.v1
137```
138
139## Change History
140
141- *2015-09-19* -- Stable v2.1.0 release.
142    - Added `command.Default()` to specify a default command to use if no other
143      command matches. This allows for convenient user shortcuts.
144    - Exposed `HelpFlag` and `VersionFlag` for further customisation.
145    - `Action()` and `PreAction()` added and both now support an arbitrary
146      number of callbacks.
147    - `kingpin.SeparateOptionalFlagsUsageTemplate`.
148    - `--help-long` and `--help-man` (hidden by default) flags.
149    - Flags are "interspersed" by default, but can be disabled with `app.Interspersed(false)`.
150    - Added flags for all simple builtin types (int8, uint16, etc.) and slice variants.
151    - Use `app.Writer(os.Writer)` to specify the default writer for all output functions.
152    - Dropped `os.Writer` prefix from all printf-like functions.
153
154- *2015-05-22* -- Stable v2.0.0 release.
155    - Initial stable release of v2.0.0.
156    - Fully supports interspersed flags, commands and arguments.
157    - Flags can be present at any point after their logical definition.
158    - Application.Parse() terminates if commands are present and a command is not parsed.
159    - Dispatch() -> Action().
160    - Actions are dispatched after all values are populated.
161    - Override termination function (defaults to os.Exit).
162    - Override output stream (defaults to os.Stderr).
163    - Templatised usage help, with default and compact templates.
164    - Make error/usage functions more consistent.
165    - Support argument expansion from files by default (with @<file>).
166    - Fully public data model is available via .Model().
167    - Parser has been completely refactored.
168    - Parsing and execution has been split into distinct stages.
169    - Use `go generate` to generate repeated flags.
170    - Support combined short-flag+argument: -fARG.
171
172- *2015-01-23* -- Stable v1.3.4 release.
173    - Support "--" for separating flags from positional arguments.
174    - Support loading flags from files (ParseWithFileExpansion()). Use @FILE as an argument.
175    - Add post-app and post-cmd validation hooks. This allows arbitrary validation to be added.
176    - A bunch of improvements to help usage and formatting.
177    - Support arbitrarily nested sub-commands.
178
179- *2014-07-08* -- Stable v1.2.0 release.
180    - Pass any value through to `Strings()` when final argument.
181      Allows for values that look like flags to be processed.
182    - Allow `--help` to be used with commands.
183    - Support `Hidden()` flags.
184    - Parser for [units.Base2Bytes](https://github.com/alecthomas/units)
185      type. Allows for flags like `--ram=512MB` or `--ram=1GB`.
186    - Add an `Enum()` value, allowing only one of a set of values
187      to be selected. eg. `Flag(...).Enum("debug", "info", "warning")`.
188
189- *2014-06-27* -- Stable v1.1.0 release.
190    - Bug fixes.
191    - Always return an error (rather than panicing) when misconfigured.
192    - `OpenFile(flag, perm)` value type added, for finer control over opening files.
193    - Significantly improved usage formatting.
194
195- *2014-06-19* -- Stable v1.0.0 release.
196    - Support [cumulative positional](#consuming-all-remaining-arguments) arguments.
197    - Return error rather than panic when there are fatal errors not caught by
198      the type system. eg. when a default value is invalid.
199    - Use gokpg.in.
200
201- *2014-06-10* -- Place-holder streamlining.
202    - Renamed `MetaVar` to `PlaceHolder`.
203    - Removed `MetaVarFromDefault`. Kingpin now uses [heuristics](#place-holders-in-help)
204      to determine what to display.
205
206## Examples
207
208### Simple Example
209
210Kingpin can be used for simple flag+arg applications like so:
211
212```
213$ ping --help
214usage: ping [<flags>] <ip> [<count>]
215
216Flags:
217  --debug            Enable debug mode.
218  --help             Show help.
219  -t, --timeout=5s   Timeout waiting for ping.
220
221Args:
222  <ip>        IP address to ping.
223  [<count>]   Number of packets to send
224$ ping 1.2.3.4 5
225Would ping: 1.2.3.4 with timeout 5s and count 5
226```
227
228From the following source:
229
230```go
231package main
232
233import (
234  "fmt"
235
236  "gopkg.in/alecthomas/kingpin.v2"
237)
238
239var (
240  debug   = kingpin.Flag("debug", "Enable debug mode.").Bool()
241  timeout = kingpin.Flag("timeout", "Timeout waiting for ping.").Default("5s").OverrideDefaultFromEnvar("PING_TIMEOUT").Short('t').Duration()
242  ip      = kingpin.Arg("ip", "IP address to ping.").Required().IP()
243  count   = kingpin.Arg("count", "Number of packets to send").Int()
244)
245
246func main() {
247  kingpin.Version("0.0.1")
248  kingpin.Parse()
249  fmt.Printf("Would ping: %s with timeout %s and count %d\n", *ip, *timeout, *count)
250}
251```
252
253### Complex Example
254
255Kingpin can also produce complex command-line applications with global flags,
256subcommands, and per-subcommand flags, like this:
257
258```
259$ chat --help
260usage: chat [<flags>] <command> [<flags>] [<args> ...]
261
262A command-line chat application.
263
264Flags:
265  --help              Show help.
266  --debug             Enable debug mode.
267  --server=127.0.0.1  Server address.
268
269Commands:
270  help [<command>]
271    Show help for a command.
272
273  register <nick> <name>
274    Register a new user.
275
276  post [<flags>] <channel> [<text>]
277    Post a message to a channel.
278
279$ chat help post
280usage: chat [<flags>] post [<flags>] <channel> [<text>]
281
282Post a message to a channel.
283
284Flags:
285  --image=IMAGE  Image to post.
286
287Args:
288  <channel>  Channel to post to.
289  [<text>]   Text to post.
290
291$ chat post --image=~/Downloads/owls.jpg pics
292...
293```
294
295From this code:
296
297```go
298package main
299
300import (
301  "os"
302  "strings"
303  "gopkg.in/alecthomas/kingpin.v2"
304)
305
306var (
307  app      = kingpin.New("chat", "A command-line chat application.")
308  debug    = app.Flag("debug", "Enable debug mode.").Bool()
309  serverIP = app.Flag("server", "Server address.").Default("127.0.0.1").IP()
310
311  register     = app.Command("register", "Register a new user.")
312  registerNick = register.Arg("nick", "Nickname for user.").Required().String()
313  registerName = register.Arg("name", "Name of user.").Required().String()
314
315  post        = app.Command("post", "Post a message to a channel.")
316  postImage   = post.Flag("image", "Image to post.").File()
317  postChannel = post.Arg("channel", "Channel to post to.").Required().String()
318  postText    = post.Arg("text", "Text to post.").Strings()
319)
320
321func main() {
322  switch kingpin.MustParse(app.Parse(os.Args[1:])) {
323  // Register user
324  case register.FullCommand():
325    println(*registerNick)
326
327  // Post message
328  case post.FullCommand():
329    if *postImage != nil {
330    }
331    text := strings.Join(*postText, " ")
332    println("Post:", text)
333  }
334}
335```
336
337## Reference Documentation
338
339### Displaying errors and usage information
340
341Kingpin exports a set of functions to provide consistent errors and usage
342information to the user.
343
344Error messages look something like this:
345
346    <app>: error: <message>
347
348The functions on `Application` are:
349
350Function | Purpose
351---------|--------------
352`Errorf(format, args)` | Display a printf formatted error to the user.
353`Fatalf(format, args)` | As with Errorf, but also call the termination handler.
354`FatalUsage(format, args)` | As with Fatalf, but also print contextual usage information.
355`FatalUsageContext(context, format, args)` | As with Fatalf, but also print contextual usage information from a `ParseContext`.
356`FatalIfError(err, format, args)` | Conditionally print an error prefixed with format+args, then call the termination handler
357
358There are equivalent global functions in the kingpin namespace for the default
359`kingpin.CommandLine` instance.
360
361### Sub-commands
362
363Kingpin supports nested sub-commands, with separate flag and positional
364arguments per sub-command. Note that positional arguments may only occur after
365sub-commands.
366
367For example:
368
369```go
370var (
371  deleteCommand     = kingpin.Command("delete", "Delete an object.")
372  deleteUserCommand = deleteCommand.Command("user", "Delete a user.")
373  deleteUserUIDFlag = deleteUserCommand.Flag("uid", "Delete user by UID rather than username.")
374  deleteUserUsername = deleteUserCommand.Arg("username", "Username to delete.")
375  deletePostCommand = deleteCommand.Command("post", "Delete a post.")
376)
377
378func main() {
379  switch kingpin.Parse() {
380  case "delete user":
381  case "delete post":
382  }
383}
384```
385
386### Custom Parsers
387
388Kingpin supports both flag and positional argument parsers for converting to
389Go types. For example, some included parsers are `Int()`, `Float()`,
390`Duration()` and `ExistingFile()` (see [parsers.go](./parsers.go) for a complete list of included parsers).
391
392Parsers conform to Go's [`flag.Value`](http://godoc.org/flag#Value)
393interface, so any existing implementations will work.
394
395For example, a parser for accumulating HTTP header values might look like this:
396
397```go
398type HTTPHeaderValue http.Header
399
400func (h *HTTPHeaderValue) Set(value string) error {
401  parts := strings.SplitN(value, ":", 2)
402  if len(parts) != 2 {
403    return fmt.Errorf("expected HEADER:VALUE got '%s'", value)
404  }
405  (*http.Header)(h).Add(parts[0], parts[1])
406  return nil
407}
408
409func (h *HTTPHeaderValue) String() string {
410  return ""
411}
412```
413
414As a convenience, I would recommend something like this:
415
416```go
417func HTTPHeader(s Settings) (target *http.Header) {
418  target = &http.Header{}
419  s.SetValue((*HTTPHeaderValue)(target))
420  return
421}
422```
423
424You would use it like so:
425
426```go
427headers = HTTPHeader(kingpin.Flag("header", "Add a HTTP header to the request.").Short('H'))
428```
429
430### Repeatable flags
431
432Depending on the `Value` they hold, some flags may be repeated. The
433`IsCumulative() bool` function on `Value` tells if it's safe to call `Set()`
434multiple times or if an error should be raised if several values are passed.
435
436The built-in `Value`s returning slices and maps, as well as `Counter` are
437examples of `Value`s that make a flag repeatable.
438
439### Boolean values
440
441Boolean values are uniquely managed by Kingpin. Each boolean flag will have a negative complement:
442`--<name>` and `--no-<name>`.
443
444### Default Values
445
446The default value is the zero value for a type. This can be overridden with
447the `Default(value...)` function on flags and arguments. This function accepts
448one or several strings, which are parsed by the value itself, so they *must*
449be compliant with the format expected.
450
451### Place-holders in Help
452
453The place-holder value for a flag is the value used in the help to describe
454the value of a non-boolean flag.
455
456The value provided to PlaceHolder() is used if provided, then the value
457provided by Default() if provided, then finally the capitalised flag name is
458used.
459
460Here are some examples of flags with various permutations:
461
462    --name=NAME           // Flag(...).String()
463    --name="Harry"        // Flag(...).Default("Harry").String()
464    --name=FULL-NAME      // Flag(...).PlaceHolder("FULL-NAME").Default("Harry").String()
465
466### Consuming all remaining arguments
467
468A common command-line idiom is to use all remaining arguments for some
469purpose. eg. The following command accepts an arbitrary number of
470IP addresses as positional arguments:
471
472    ./cmd ping 10.1.1.1 192.168.1.1
473
474Such arguments are similar to [repeatable flags](#repeatable-flags), but for
475arguments. Therefore they use the same `IsCumulative() bool` function on the
476underlying `Value`, so the built-in `Value`s for which the `Set()` function
477can be called several times will consume multiple arguments.
478
479To implement the above example with a custom `Value`, we might do something
480like this:
481
482```go
483type ipList []net.IP
484
485func (i *ipList) Set(value string) error {
486  if ip := net.ParseIP(value); ip == nil {
487    return fmt.Errorf("'%s' is not an IP address", value)
488  } else {
489    *i = append(*i, ip)
490    return nil
491  }
492}
493
494func (i *ipList) String() string {
495  return ""
496}
497
498func (i *ipList) IsCumulative() bool {
499  return true
500}
501
502func IPList(s Settings) (target *[]net.IP) {
503  target = new([]net.IP)
504  s.SetValue((*ipList)(target))
505  return
506}
507```
508
509And use it like so:
510
511```go
512ips := IPList(kingpin.Arg("ips", "IP addresses to ping."))
513```
514
515### Bash/ZSH Shell Completion
516
517By default, all flags and commands/subcommands generate completions
518internally.
519
520Out of the box, CLI tools using kingpin should be able to take advantage
521of completion hinting for flags and commands. By specifying
522`--completion-bash` as the first argument, your CLI tool will show
523possible subcommands. By ending your argv with `--`, hints for flags
524will be shown.
525
526To allow your end users to take advantage you must package a
527`/etc/bash_completion.d` script with your distribution (or the equivalent
528for your target platform/shell). An alternative is to instruct your end
529user to source a script from their `bash_profile` (or equivalent).
530
531Fortunately Kingpin makes it easy to generate or source a script for use
532with end users shells. `./yourtool --completion-script-bash` and
533`./yourtool --completion-script-zsh` will generate these scripts for you.
534
535**Installation by Package**
536
537For the best user experience, you should bundle your pre-created
538completion script with your CLI tool and install it inside
539`/etc/bash_completion.d` (or equivalent). A good suggestion is to add
540this as an automated step to your build pipeline, in the implementation
541is improved for bug fixed.
542
543**Installation by `bash_profile`**
544
545Alternatively, instruct your users to add an additional statement to
546their `bash_profile` (or equivalent):
547
548```
549eval "$(your-cli-tool --completion-script-bash)"
550```
551
552Or for ZSH
553
554```
555eval "$(your-cli-tool --completion-script-zsh)"
556```
557
558#### Additional API
559To provide more flexibility, a completion option API has been
560exposed for flags to allow user defined completion options, to extend
561completions further than just EnumVar/Enum.
562
563
564**Provide Static Options**
565
566When using an `Enum` or `EnumVar`, users are limited to only the options
567given. Maybe we wish to hint possible options to the user, but also
568allow them to provide their own custom option. `HintOptions` gives
569this functionality to flags.
570
571```
572app := kingpin.New("completion", "My application with bash completion.")
573app.Flag("port", "Provide a port to connect to").
574    Required().
575    HintOptions("80", "443", "8080").
576    IntVar(&c.port)
577```
578
579**Provide Dynamic Options**
580Consider the case that you needed to read a local database or a file to
581provide suggestions. You can dynamically generate the options
582
583```
584func listHosts() []string {
585  // Provide a dynamic list of hosts from a hosts file or otherwise
586  // for bash completion. In this example we simply return static slice.
587
588  // You could use this functionality to reach into a hosts file to provide
589  // completion for a list of known hosts.
590  return []string{"sshhost.example", "webhost.example", "ftphost.example"}
591}
592
593app := kingpin.New("completion", "My application with bash completion.")
594app.Flag("flag-1", "").HintAction(listHosts).String()
595```
596
597**EnumVar/Enum**
598When using `Enum` or `EnumVar`, any provided options will be automatically
599used for bash autocompletion. However, if you wish to provide a subset or
600different options, you can use `HintOptions` or `HintAction` which will override
601the default completion options for `Enum`/`EnumVar`.
602
603
604**Examples**
605You can see an in depth example of the completion API within
606`examples/completion/main.go`
607
608
609### Supporting -h for help
610
611`kingpin.CommandLine.HelpFlag.Short('h')`
612
613### Custom help
614
615Kingpin v2 supports templatised help using the text/template library (actually, [a fork](https://github.com/alecthomas/template)).
616
617You can specify the template to use with the [Application.UsageTemplate()](http://godoc.org/gopkg.in/alecthomas/kingpin.v2#Application.UsageTemplate) function.
618
619There are four included templates: `kingpin.DefaultUsageTemplate` is the default,
620`kingpin.CompactUsageTemplate` provides a more compact representation for more complex command-line structures,
621`kingpin.SeparateOptionalFlagsUsageTemplate` looks like the default template, but splits required
622and optional command flags into separate lists, and `kingpin.ManPageTemplate` is used to generate man pages.
623
624See the above templates for examples of usage, and the the function [UsageForContextWithTemplate()](https://github.com/alecthomas/kingpin/blob/master/usage.go#L198) method for details on the context.
625
626#### Default help template
627
628```
629$ go run ./examples/curl/curl.go --help
630usage: curl [<flags>] <command> [<args> ...]
631
632An example implementation of curl.
633
634Flags:
635  --help            Show help.
636  -t, --timeout=5s  Set connection timeout.
637  -H, --headers=HEADER=VALUE
638                    Add HTTP headers to the request.
639
640Commands:
641  help [<command>...]
642    Show help.
643
644  get url <url>
645    Retrieve a URL.
646
647  get file <file>
648    Retrieve a file.
649
650  post [<flags>] <url>
651    POST a resource.
652```
653
654#### Compact help template
655
656```
657$ go run ./examples/curl/curl.go --help
658usage: curl [<flags>] <command> [<args> ...]
659
660An example implementation of curl.
661
662Flags:
663  --help            Show help.
664  -t, --timeout=5s  Set connection timeout.
665  -H, --headers=HEADER=VALUE
666                    Add HTTP headers to the request.
667
668Commands:
669  help [<command>...]
670  get [<flags>]
671    url <url>
672    file <file>
673  post [<flags>] <url>
674```
675