NOAA Observations v0.4.31 NOAA.Observations.CLI View Source
Parses the command line and generates a table of observations from the NOAA Weather Service.
Exercise in the book Programming Elixir by Dave Thomas.
Link to this section Summary
Link to this section Types
Link to this type
bell()
View Source
bell()
View Source
bell() :: boolean()
bell() :: boolean()
Link to this type
count()
View Source
count()
View Source
count() :: integer()
count() :: integer()
Link to this type
parsed()
View Source
parsed()
View Source
parsed() :: {state(), count(), bell(), IO.ANSI.Table.Style.t()} | :help
parsed() :: {state(), count(), bell(), IO.ANSI.Table.Style.t()} | :help
Link to this type
state()
View Source
state()
View Source
state() :: String.t()
state() :: String.t()
Link to this type
stn()
View Source
stn()
View Source
stn() :: String.t()
stn() :: String.t()
Link to this section Functions
Link to this function
main(argv) View Source
Parses and processes argv
(command line arguments).
Parameters
argv
- command line arguments (list)
Link to this function
parse(argv) View Source
Parses argv
(command line arguments).
argv
can be ["-h"] or ["--help"], which returns :help. Otherwise
it contains a US state/territory code (case-insensitive) and optionally
the number of observations to format (the first n ones). To format the
last n observations, specify switch --last
which will return a
negative count. To ring the bell, specify switch --bell
.
To apply a specific table style, use switch --table-style
.
Returns either a tuple of {state, count, bell, table_style}
or :help if --help
was specified.
Parameters
argv
- command line arguments (list)
Switches
-h
or--help
- for help-l
or--last
- to format the last n observations-b
or--bell
- to ring the bell-t
or--table-style
- to apply a specific table style
Table styles
bare
- no colorsbarish
- like bare but coloredcyan
- cyan backgroundcyan-alt
- cyan header, alternating row colorscyan-border
- light cyan bordercyan-mult
- cyan header, 3 repeating row colorsdark
- dark colorsdark-alt
- dark colors, alternating row colorsdark-mult
- dark colors, 3 repeating row colorsdashed
- no colorsdotted
- slightly coloreddotted-alt
- slightly colored, alternating row colorsdotted-mult
- slightly colored, 3 repeating row colorsgame
- game boardgreen
- green backgroundgreen-alt
- green header, alternating row colorsgreen-border
- light green bordergreen-border-padded
- light green border with extra paddinggreen-border-unpadded
- light green border without paddinggreen-mult
- green header, 3 repeating row colorsgreen-padded
- like green but with extra paddinggreen-unpadded
- like green but without paddinglight
- light colorslight-alt
- light colors, alternating row colorslight-mult
- light colors, 3 repeating row colorsmedium
- medium colorsmedium-alt
- medium colors, alternating row colorsmedium-mult
- medium colors, 3 repeating row colorsmixed
- fillers revealedplain
- slightly coloredpretty
- multicoloredpretty-alt
- multicolored, alternating row colorspretty-mult
- multicolored, 3 repeating row colorstest
- no colorsyellow
- light yellow backgroundyellow-border
- light yellow border
Examples
iex> alias NOAA.Observations.CLI
iex> CLI.parse ["-h"]
:help
iex> alias NOAA.Observations.CLI
iex> CLI.parse ["vt", "99"]
{"vt", 99, false, :dark}
iex> alias NOAA.Observations.CLI
iex> CLI.parse ["TX", "88", "--last", "--bell"]
{"tx", -88, true, :dark}
iex> alias NOAA.Observations.CLI
iex> CLI.parse ["nc", "6", "--table-style", "cyan"]
{"nc", 6, false, :cyan}