cmd

package
v0.0.0-...-02e100b Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "bcat",
	Short: "pipe to browser utility",
	Long: `Usage: bcat [-htp] [-a] [-b <browser>] [-T <title>] [<file>]...
Pipe to browser utility. Read standard input, possibly one or more <file>s,
and write concatenated / formatted output to browser. When invoked as btee,
also write all input back to standard output.

Display options:
  -b, --browser=<browser>    open <browser> instead of system default browser
  -T, --title=<text>         use <text> as the browser title
  -a, --ansi                 convert ANSI (color) escape sequences to HTML

Input format (auto detected by default):
  --html                 input is already HTML encoded, doc or fragment
  --text                 input is unencoded text

Misc options:
  -p, --persist              serve until interrupted, allowing reload
  -d, --debug                enable verbose debug logging on stderr`,

	Run: func(cmd *cobra.Command, args []string) {
		rc, err := bcatlib.NewReaderCollection(args)
		if err != nil {
			fmt.Fprintf(os.Stderr, "error: %s\n", err)
		}
		ch := rc.MakeFilterableChan()
		if options.Ansi {
			options.Html = true
			ch = bcatlib.TextFilter(ch)
		}
		done, url := bcatlib.ServerEndpoint(ch)

		browserCommand := viper.GetString("BCAT_COMMAND")
		b, err := bcatlib.NewBrowser(options.Browser, browserCommand)
		if err != nil {
			fmt.Fprintf(os.Stderr, "error: %s\n", err)
		}
		if err := b.Open(url); err != nil {
			fmt.Fprintf(os.Stderr, "error: %s\n", err)
		}
		fmt.Println(url)
		<-done
	},
}

RootCmd represents the base command when called without any subcommands

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