cmd

package
v0.0.0-...-f5e5340 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const BASH_COMPLETION_FILENAME = "ltst-completion.sh"
View Source
const COMMAND_KEY = "command"
View Source
const CONFIG_DIR = "$HOME"
View Source
const CONFIG_FILENAME = ".ltst"
View Source
const CONFIG_FILE_TYPE = "yaml"
View Source
const CONFIG_FULL_PATH = CONFIG_DIR + "/" + CONFIG_FILENAME + "." + CONFIG_FILE_TYPE
View Source
const GEN_AUTOCOMPLETE_FLAG = "gen-autocomplete"

Flags

View Source
const LONG_DESC_KEY = "longDescription"
View Source
const NAME_KEY = "name"
View Source
const NUM_RESULTS_FLAG = "num"
View Source
const OPEN_FLAG = "open"
View Source
const QUERY_KEY = "query"
View Source
const SHORT_DESC_KEY = "shortDescription"

Optional config keys

View Source
const URL_KEY = "url"

Required config keys

Variables

View Source
var REQUIRED_CONFIG = [...]string{URL_KEY, QUERY_KEY, NAME_KEY, COMMAND_KEY}
View Source
var RootCmd = &cobra.Command{
	Use:   "ltst",
	Short: "Get the latest news",
	Long:  "Get the latest news from all of your favorite sites! Fetched in parallel!",
	Run: func(cmd *cobra.Command, args []string) {
		shouldGenerateAutocomplete, err := cmd.Flags().GetBool(GEN_AUTOCOMPLETE_FLAG)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Error reading %s flag: %s\n", GEN_AUTOCOMPLETE_FLAG, err)
			return
		}

		if shouldGenerateAutocomplete {
			cmd.GenBashCompletionFile(BASH_COMPLETION_FILENAME)
			return
		}

		numResultsPerCommand, err := cmd.Flags().GetInt(NUM_RESULTS_FLAG)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Error reading %s flag: %s\n", NUM_RESULTS_FLAG, err)
			return
		}

		parallelPrintLatestOfAllCommands(cmd, numResultsPerCommand)
	},
}

RootCmd is the base command that defines this cobra app. In this case, it is ltst.

Functions

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL