Skip to content

Commit

Permalink
Merge pull request #29 from jingweno/show_version
Browse files Browse the repository at this point in the history
Show version
  • Loading branch information
owenthereal committed Jun 14, 2015
2 parents 4a1cd45 + f6ba4bb commit 0683e07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ type ccatCmd struct {
Color string
ColorCodes mapValue
ShowPalette bool
ShowVersion bool
}

func (c *ccatCmd) Run(cmd *cobra.Command, args []string) {
stdout := colorable.NewColorableStdout()

if c.ShowVersion {
displayVersion(stdout)
return
}

var colorPalettes ColorPalettes
if c.BG == "dark" {
colorPalettes = DarkColorPalettes
Expand Down Expand Up @@ -66,7 +74,6 @@ Value of color can be %s
args = []string{readFromStdin}
}

stdout := colorable.NewColorableStdout()
for _, arg := range args {
err := CCat(arg, printer, stdout)
if err != nil {
Expand Down Expand Up @@ -110,6 +117,7 @@ Examples:
rootCmd.PersistentFlags().StringVarP(&ccatCmd.Color, "color", "C", "auto", `colorize the output; value can be "never", "always" or "auto"`)
rootCmd.PersistentFlags().VarP(&ccatCmd.ColorCodes, "color-code", "G", `set color codes`)
rootCmd.PersistentFlags().BoolVarP(&ccatCmd.ShowPalette, "palette", "", false, `show color palettes`)
rootCmd.PersistentFlags().BoolVarP(&ccatCmd.ShowVersion, "version", "v", false, `show version`)

rootCmd.Execute()
}
11 changes: 10 additions & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
package main

const Version = "0.1.0"
import (
"fmt"
"io"
)

const Version = "1.0.0"

func displayVersion(w io.Writer) {
fmt.Fprintf(w, "ccat v%s\n", Version)
}

0 comments on commit 0683e07

Please sign in to comment.