Skip to content

Commit

Permalink
feat: Added version command to CLI tool
Browse files Browse the repository at this point in the history
  • Loading branch information
SEQUOIIA committed Feb 11, 2018
1 parent 473fa22 commit dceac42
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
9 changes: 9 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var (
Verbose bool
ConcurrentDownloads int
BandwidthLimit int64
PrintVersion bool
)

var rootCmd = &cobra.Command{
Expand All @@ -36,6 +37,11 @@ var rootCmd = &cobra.Command{
downloader.Remux(vodOptions)
},
Args: func(cmd *cobra.Command, args[]string) error{
if PrintVersion {
versionCmd.Run(cmd, args)
os.Exit(1)
}

if len(args) < 1 {
return errors.New("Requires at least one arg(url)")
}
Expand All @@ -57,4 +63,7 @@ func Init() {
rootCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "Verbose output")
rootCmd.PersistentFlags().IntVarP(&ConcurrentDownloads, "concurrent-download", "c", 1, "The amount of video segments downloaded at the same time.")
rootCmd.PersistentFlags().Int64VarP(&BandwidthLimit, "bwlimit", "b", math.MaxInt64, "Limits download speed, value is in kb/s")
rootCmd.PersistentFlags().BoolVar(&PrintVersion, "version", false, "Print software version")

rootCmd.AddCommand(versionCmd)
}
18 changes: 18 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

const VERSION string = "0.9.8"

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of twiVod",
Long: "Print the version number of twiVod",
Run: func(cmd *cobra.Command, args[]string) {
fmt.Printf("twiVod v%s\n", VERSION)
},
}
28 changes: 15 additions & 13 deletions utilities/downloader/twitchoauth.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
package downloader

import (
"net/http"
"net/url"
"html/template"
"io/ioutil"
"bufio"
"bytes"
"sync"
"github.com/sequoiia/twivod/models"
"encoding/json"
"fmt"
"regexp"
"github.com/skratchdot/open-golang/open"
"os/exec"
"os"
"html/template"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"os/exec"
"regexp"
"sync"

"github.com/GeertJohan/go.rice"
"github.com/sequoiia/twivod/internal/github.com/grafov/m3u8"
"bufio"
"github.com/codegangsta/negroni"
"github.com/gorilla/mux"
"github.com/codegangsta/negroni")
"github.com/sequoiia/twivod/internal/github.com/grafov/m3u8"
"github.com/sequoiia/twivod/models"
"github.com/skratchdot/open-golang/open"
)

const CtxSpanID = 0

Expand Down

0 comments on commit dceac42

Please sign in to comment.