We want AWESOME CLI tool & development

We want AWESOME CLI tool & development

2e1e9884fb61b5c0014818fc7e080f25?s=128

micnncim

May 18, 2019
Tweet

Transcript

  1. We want AWESOME CLI tool & development Go Conference 2019

    Spring @micnncim
  2. $ whoami @micnncim @micnncim University Student (CS/B4) No Job (Welcome

    job opportunity!) Blog: https://micnncim.github.io/
  3. CLI, UNIX, Go

  4. None
  5. A Quarter-Century of Unix (1994) Write programs that do one

    thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
  6. Why Go for CLI? ば ば

  7. What component? ば Argument/Flag/(Subcommand) ば I/O (Standard Stream) ば Exit

    Code
  8. What needed for awesome CLI? ば UX/DX ば ば ば

  9. Design and Test CLI

  10. Design & Test I/O ば fmt.Println() Testable ば io.Writer ば

    I/O interface
  11. Design I/O

  12. Test I/O

  13. Design I/O

  14. Design I/O From github/hub

  15. Design I/O From mitchellh/cli

  16. Test I/O ば bytes.Bu er

  17. Handling Exit Code ば error Exit Code 0 ば Exit

    Code ば Exit Code error type
  18. Handling Exit Code From github/hub

  19. Test with golden files ば ( ) .golden ば API

    .golden
  20. Test with golden files

  21. Test with golden files ば testdata/expect.golden

  22. Test with golden files

  23. Cross Platform

  24. Support Cross Platform ば Go Linux/macOS/Windows ば Utility

  25. Pkgs for Cross Platform ば Home Directory: mitchellh/go-homedir ば Open

    ( | URL): skratchdot/open-golang ば Color: mattn/go-colorable
  26. Pkgs for Cross Platform From mitchellh/go-homedir

  27. Build & Release CLI

  28. Build & Release ば $ go get potentially unstable, Go

    ば GitHub Release curl + tar + chmod? ば
  29. Build & Release ば mitchellh/gox: ば tcnksm/ghr: ば goreleaser/goreleaser: ,

    , etc.
  30. GoReleaser ば YAML ば Homebrew ば CI easy

  31. GoReleaser: Build ば YAML ば DX

  32. GoReleaser: Changelog ば Changelog = UX

  33. GoReleaser: Package Manager ば Formula ば DX ば UX

  34. CI/CD ば tag push CI

  35. CI/CD ば GoReleaser dead simple GoReleaser dead simple

  36. Update ば ば CLI GUI ば rhysd/go-github-selfupdate tj/go-update

  37. Auto Update

  38. Document CLI

  39. Documentation ば Go ( | ) ば ば ( )

  40. Demo ば GIF? SVG? ば troublesome ば asciinema + (asciicast2gif

    | svg-term-cli)
  41. Demo

  42. Develop Rich CLI

  43. Awesome CLI packages ば All in One ば Flag Parser

    ば Standard Stream ば Progress UI ば Con guration
  44. All in One ば urfave/cli 10,714 ば spf13/cobra 11,958 ば

    mitchellh/cli 966 , , , etc.
  45. All in One

  46. Flag Parser ば alecthomas/kingpin 2,431 ば jessevdk/go- ags 1,458 ,

    , ag/argument, ag parse
  47. Flag Parser

  48. Standard Stream ば manifoldco/promptui 2,803 ば AlecAivazis/survey 1,144 validation, Select,

    Con rm, Password UI UX Stdin UI Utility
  49. Standard Stream

  50. Progress UI ば cheggaaa/pb 1,878 ば gosuri/uiprogress 1,400 ば briandowns/spinner

    734 I/O , Spinner UI
  51. Progress UI

  52. Configuration ば spf13/viper 8,467 JSON/TOML/YAML/HCL Con g , , Path

  53. Example

  54. micnncim/bitbrew ✔ Document, Demo

  55. micnncim/bitbrew ✔

  56. micnncim/bitbrew ✔

  57. micnncim/bitbrew ✔ Testable I/O

  58. micnncim/bitbrew ✔ Con g

  59. micnncim/bitbrew ✔ Rich UI

  60. micnncim/bitbrew ✔ Installation

  61. See also ば golang/go ば hashicorp/consul, terraform, nomad, packer, etc.

  62. @micnncim Thank you!