Skip to content
Permalink
Browse files

Using CLI command formatting

  • Loading branch information...
s32x committed Dec 16, 2018
1 parent d9cdee4 commit 5b6c5332af39981bab1a2ecb83bb5becfa093406
Showing with 13,113 additions and 11 deletions.
  1. +1 −0 README.md
  2. +4 −2 glide.lock
  3. +1 −0 glide.yaml
  4. +38 −9 main.go
  5. +2 −0 vendor/github.com/urfave/cli/.flake8
  6. +2 −0 vendor/github.com/urfave/cli/.gitignore
  7. +27 −0 vendor/github.com/urfave/cli/.travis.yml
  8. +435 −0 vendor/github.com/urfave/cli/CHANGELOG.md
  9. +74 −0 vendor/github.com/urfave/cli/CODE_OF_CONDUCT.md
  10. +19 −0 vendor/github.com/urfave/cli/CONTRIBUTING.md
  11. +21 −0 vendor/github.com/urfave/cli/LICENSE
  12. +1 −0 vendor/github.com/urfave/cli/MAINTAINERS.md
  13. +1,526 −0 vendor/github.com/urfave/cli/README.md
  14. +3 −0 vendor/github.com/urfave/cli/altsrc/altsrc.go
  15. +261 −0 vendor/github.com/urfave/cli/altsrc/flag.go
  16. +347 −0 vendor/github.com/urfave/cli/altsrc/flag_generated.go
  17. +336 −0 vendor/github.com/urfave/cli/altsrc/flag_test.go
  18. +18 −0 vendor/github.com/urfave/cli/altsrc/helpers_test.go
  19. +21 −0 vendor/github.com/urfave/cli/altsrc/input_source_context.go
  20. +324 −0 vendor/github.com/urfave/cli/altsrc/json_command_test.go
  21. +208 −0 vendor/github.com/urfave/cli/altsrc/json_source_context.go
  22. +262 −0 vendor/github.com/urfave/cli/altsrc/map_input_source.go
  23. +310 −0 vendor/github.com/urfave/cli/altsrc/toml_command_test.go
  24. +113 −0 vendor/github.com/urfave/cli/altsrc/toml_file_loader.go
  25. +313 −0 vendor/github.com/urfave/cli/altsrc/yaml_command_test.go
  26. +92 −0 vendor/github.com/urfave/cli/altsrc/yaml_file_loader.go
  27. +508 −0 vendor/github.com/urfave/cli/app.go
  28. +1,846 −0 vendor/github.com/urfave/cli/app_test.go
  29. +26 −0 vendor/github.com/urfave/cli/appveyor.yml
  30. +16 −0 vendor/github.com/urfave/cli/autocomplete/bash_autocomplete
  31. +11 −0 vendor/github.com/urfave/cli/autocomplete/zsh_autocomplete
  32. +44 −0 vendor/github.com/urfave/cli/category.go
  33. +22 −0 vendor/github.com/urfave/cli/cli.go
  34. +383 −0 vendor/github.com/urfave/cli/command.go
  35. +363 −0 vendor/github.com/urfave/cli/command_test.go
  36. +287 −0 vendor/github.com/urfave/cli/context.go
  37. +403 −0 vendor/github.com/urfave/cli/context_test.go
  38. +115 −0 vendor/github.com/urfave/cli/errors.go
  39. +122 −0 vendor/github.com/urfave/cli/errors_test.go
  40. +93 −0 vendor/github.com/urfave/cli/flag-types.json
  41. +786 −0 vendor/github.com/urfave/cli/flag.go
  42. +640 −0 vendor/github.com/urfave/cli/flag_generated.go
  43. +1,354 −0 vendor/github.com/urfave/cli/flag_test.go
  44. +44 −0 vendor/github.com/urfave/cli/funcs.go
  45. +256 −0 vendor/github.com/urfave/cli/generate-flag-types
  46. +345 −0 vendor/github.com/urfave/cli/help.go
  47. +452 −0 vendor/github.com/urfave/cli/help_test.go
  48. +28 −0 vendor/github.com/urfave/cli/helpers_test.go
  49. +9 −0 vendor/github.com/urfave/cli/helpers_unix_test.go
  50. +20 −0 vendor/github.com/urfave/cli/helpers_windows_test.go
  51. +122 −0 vendor/github.com/urfave/cli/runtests
  52. +29 −0 vendor/github.com/urfave/cli/sort.go
  53. +30 −0 vendor/github.com/urfave/cli/sort_test.go
@@ -26,6 +26,7 @@ $ go get s32x.com/anirip
### Usage
To download shows from Crunchyroll :
```
anirip --help
anirip myUsername0123 myPassword5535 http://www.crunchyroll.com/strike-the-blood
```

Some generated files are not rendered by default. Learn more.

@@ -3,4 +3,5 @@ import:
- package: github.com/PuerkitoBio/goquery
- package: github.com/fatih/color
- package: github.com/robertkrimen/otto
- package: github.com/urfave/cli
- package: s32x.com/httpclient
47 main.go
@@ -1,10 +1,12 @@
package main /* import "s32x.com/anirip" */

import (
"fmt"
"math/rand"
"os"
"time"

"github.com/urfave/cli"
"s32x.com/anirip/common"
"s32x.com/anirip/common/log"
"s32x.com/anirip/crunchyroll"
@@ -30,19 +32,46 @@ var (
func main() {
// Seed the random number generator
rand.Seed(time.Now().UnixNano())
log.Cyan("v1.5.2(12/8/2018) - by Steven Wolfe <steven@swolfe.me>")
args := os.Args

// If the user isn't using the cli correctly give them an example of how
if len(os.Args) != 4 {
log.Warn("CLI usage : anirip username password http://www.crunchyroll.com/miss-kobayashis-dragon-maid")
return
app := cli.NewApp()
app.Name = "anirip"
app.Version = "1.5.2(12/8/2018)"
app.Author = "Steven Wolfe"
app.Email = "steven@swolfe.me"
app.Usage = "anirip username password http://www.crunchyroll.com/miss-kobayashis-dragon-maid"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "language, l",
Value: "eng",
Usage: "language code for the subtitles (not all are supported) ex: eng, esp",
},
cli.StringFlag{
Name: "quality, q",
Value: "1080",
Usage: "quality of video to download ex: 1080, 720, 480, 360, android",
},
}

app.Action = func(c *cli.Context) error {
log.Cyan("v%s - by %s <%s>", app.Version, app.Author, app.Email)
args := c.Args()
if len(args) != 3 {
log.Warn("CLI Usage : " + app.Usage)
return nil
}

download(args[2], args[0], args[1], c.String("lang"), c.String("lang"))
return nil
}

err := app.Run(os.Args)
if err != nil {
fmt.Println(err)
}
download(args[3], args[1], args[2], "1080", "eng")
}

func download(showURL, user, pass, quality, subLang string) {
// Verifies the existance of an anirip folder in our temp directory
// Verifies the existence of an anirip folder in our temp directory
_, err := os.Stat(tempDir)
if err != nil {
log.Info("Generating new temporary directory")
@@ -85,7 +114,7 @@ func download(showURL, user, pass, quality, subLang string) {

// Retrieves more fine grained episode metadata
log.Info("Retrieving Episode Info...")
if err = episode.GetEpisodeInfo(client, "1080"); err != nil {
if err = episode.GetEpisodeInfo(client, quality); err != nil {
log.Error(err)
continue
}

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

0 comments on commit 5b6c533

Please sign in to comment.
You can’t perform that action at this time.