Migrating to the new kingpin Envar() interface

This commit is contained in:
Elia el Lazkani 2020-05-06 19:46:10 +02:00
parent f1ab9a64fb
commit 4ef54af009

14
main.go
View file

@ -15,7 +15,7 @@ import (
)
// VERSION The version release
const VERSION = "0.1.3"
const VERSION = "0.1.4"
// AUTHOR The author name
const AUTHOR = "Elia el Lazkani"
@ -166,8 +166,8 @@ func generateParamFormat(switchesF []*bool, freeStyleF *string, formatF *string,
// Defining the command-line interface
var (
app = kingpin.New("go-cmw", "A small terminal wrapper around the wttr.in weather endpoint.")
location = app.Flag("location", "Specify explicite location (--expert-mode)").Short('L').OverrideDefaultFromEnvar("GO_CMW_LOCATION").String()
language = app.Flag("language", "Specify explicite language (--expert-mode)").Short('l').OverrideDefaultFromEnvar("GO_CMW_LANGUAGE").String()
location = app.Flag("location", "Specify explicite location (--expert-mode)").Short('L').Envar("GO_CMW_LOCATION").String()
language = app.Flag("language", "Specify explicite language (--expert-mode)").Short('l').Envar("GO_CMW_LANGUAGE").String()
v2 = app.Flag("v2", "Display Data-Rich output").Default("false").Bool()
switches = []*bool{
app.Flag("metric", "Display weather in metric").Short('m').Default("false").Bool(),
@ -185,12 +185,12 @@ var (
png = app.Flag("png", "Download a weather PNG image").Short('P').Default("false").Bool()
addFrame = app.Flag("add-frame", "Add a frame to the output (PNG only)").Short('p').Default("false").Bool()
transparency = app.Flag("transparency", "Set transparency level (0-255) (PNG only) (--expert-mode)").OverrideDefaultFromEnvar("GO_CMW_TRANSPARENCY").Short('t').Default("255").Int()
transparency = app.Flag("transparency", "Set transparency level (0-255) (PNG only) (--expert-mode)").Envar("GO_CMW_TRANSPARENCY").Short('t').Default("255").Int()
download = app.Flag("download", "Enables download mode (--expert-mode)").Short('d').Default("false").Bool()
fileName = app.Flag("file-name", "Name download file (--expert-mode)").OverrideDefaultFromEnvar("GO_CMW_FILE_NAME").Default("").String()
fileName = app.Flag("file-name", "Name download file (--expert-mode)").Envar("GO_CMW_FILE_NAME").Default("").String()
oneLiner = app.Flag("one-liner", "One liner outpet (for the terminal multiplexer lovers out there)").Short('O').Default("false").Bool()
format = app.Flag("format", "Specify a format query (e.g. \"%l:+%c+%t\") (--expert-mode)").OverrideDefaultFromEnvar("GO_CMW_FORMAT").String()
freeStyle = app.Flag("free-style", "Specify a free-style API call (--expert-mode)").OverrideDefaultFromEnvar("GO_CMW_FREE_STYLE").String()
format = app.Flag("format", "Specify a format query (e.g. \"%l:+%c+%t\") (--expert-mode)").Envar("GO_CMW_FORMAT").String()
freeStyle = app.Flag("free-style", "Specify a free-style API call (--expert-mode)").Envar("GO_CMW_FREE_STYLE").String()
expertMode = app.Flag("expert-mode", "Print expert mode information").Default("false").Bool()
)