NOAA.Observations.CLI (NOAA Observations v0.4.75)
View SourceParses the command line and prints a table of weather observations from the NOAA Weather Service.
Exercise in the book Programming Elixir by Dave Thomas.
Reference https://dev.to/paulasantamaria/command-line-interfaces-structure-syntax-2533
Summary
Functions
Allows to run command mix run -e 'NOAA.Observations.CLI.main()'.
Parses the command line and prints a table of weather observations from the NOAA Weather Service.
Functions
@spec main() :: :ok
Allows to run command mix run -e 'NOAA.Observations.CLI.main()'.
The above command is equivalent to:mix run -e 'NOAA.Observations.CLI.main([""ny"", ""16"", ""-t"", ""plain""])'
Examples
$env:MIX_ENV="test"; mix run -e 'NOAA.Observations.CLI.main()'
$env:MIX_ENV="dev"; mix run -e 'NOAA.Observations.CLI.main()'
$env:MIX_ENV="prod"; mix run -e 'NOAA.Observations.CLI.main()'
$env:AWAIT_TIMEOUT="111"; mix run -e 'NOAA.Observations.CLI.main()'
@spec main(OptionParser.argv()) :: :ok
Parses the command line and prints a table of weather observations from the NOAA Weather Service.
argv can be "-h" or "--help", which prints info on the command's usage and
syntax. Otherwise it is 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.
To ring the bell, specify switch --bell.
To choose a table style, specify switch --table-style.
Parameters
argv- command line arguments (list)
Switches
-hor--help- for help-bor--bell- to ring the bell-lor--last- to format the last n observations-tor--table-style- to choose a 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
alias NOAA.Observations.CLI
CLI.main(["fl", "--last", "--no-help"])
CLI.main(["tx", "--no-last"])
CLI.main(["VT", "--no-bell", "--table-style", "plain"])
CLI.main(["ca", "11", "--last"])
CLI.main(["CA", "--last", "11"])