ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
How to build and
distribute CLI tool in15
Minutes with Golang
@kohei_kimura
Today¡¯s topic:
CLI tool with Golang
Main Targets
? Beginners
? want to build something with Golang.
? have not used Golang since A Tour of Go.
? I¡¯m not a beginner!
? I¡¯d like to hear stories about parallel
processing!
Sorry, please install and try stopho, my CLI tool:
or
go get -d github.com/kohei-kimura/stopho
brew tap kohei-kimura/homebrew-stopho
brew install stopho
stopho ¡ú
CLI tool to generate search URLs from stock
photos web sites
Why CLI tools with Golang?
Why CLI tools with Golang?
A lot of library for CLI tools
Cross compile
Not have to write CSS!
Building CLI tools is
tiresome?
? sub commands
? options
? arguments
? helps ¡­
Humanity has urfave/cli
Package for building command line apps
https://github.com/urfave/cli
app.Commands = []cli.Command{
{
Name: "search", // Sub command: `stopho search`
ShortName: "s", // Alias: `stopho s`
Usage: "Generate search URLs from stock photos web sites",
Action: command.CmdSearch,
Flags: []cli.Flag{ // Options
cli.BoolFlag{ // TRUE or FALSE
Name: "japan, j", // `stopho s --japan` or `stopho s -j`
Usage: "Enable Japan mode",
},
cli.StringFlag{ // `stopho s -s $SITE_NAME`
Name: "site, s",
Usage: "Display only sites matched `value`",
},
},
},
}
func CmdSearch(c *cli.Context) {
// Arguments
term := c.Args().Get(0)
// Bool Options
if c.Bool("japan") {
// japan mode
}
// String Options
fmt.Println(c.String("site"))
}
Function
// Set Writer
outStream = new(bytes.Buffer)
app.Writer = outStream
~~~~~~
// Use `fmt.Fprintf`
fmt.Fprintf(c.App.Writer, ...)
Testing
tcnksm/gcli
? generate CLI skeleton
? urfave/cli and other CLI frameworks
Distribution
Compile by `gox`
? done!
? easy!
go get github.com/mitchellh/gox
gox
GitHub Releases
1. `Releases` tab in repository page
2. `Create a new release` button
3. Upload binary ?les
4. done!
Homebew
? ruby script for building apps
? https://github.com/Homebrew/brew/blob/
master/docs/Formula-Cookbook.md
$ brew create --set-name $APP_NAME $URL
# edit your `$APPNAME.rb`!
$ git push
Summary
Framework: urfave/cli
Generator: tcnksm/gcli
Compile tool: mitchellh/gox
Release platform: GitHub Releases
Tips
Build a simple and small tool!
Refer to famous tools! - e.g. git, docker, ¡­
Provide aliases of subcommands and options!
Add GIF animation in README.md
Promote on reddit and twitter
How to build and distribute CLI tool in 15 minutes with Golang
@kohei_kimura
? IDC Frontier Inc.
Developing IoT Platform
Back-end on the activity recognition project
@kohei_kimura
kohei-kimura
kohei-kimura.github.io
? Visual Studio Code
Kitakyushu -> Yokohama -> Fukuoka
IDCF Cloud - One coin IaaS
Enjoy your Go programming!
Please star my Stopho! ->
Please follow me! ->

More Related Content

Similar to How to build and distribute CLI tool in 15 minutes with Golang (20)

Drone CI/CD Platform
Drone CI/CD PlatformDrone CI/CD Platform
Drone CI/CD Platform
Bo-Yi Wu
?
Life of a Chromium Developer
Life of a Chromium DeveloperLife of a Chromium Developer
Life of a Chromium Developer
mpaproductions
?
Git - Some tips to do it better
Git - Some tips to do it betterGit - Some tips to do it better
Git - Some tips to do it better
Jonas De Smet
?
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
Bo-Yi Wu
?
State ofappdevelopment
State ofappdevelopmentState ofappdevelopment
State ofappdevelopment
gillygize
?
Colab workshop (for Computer vision Students)
Colab workshop (for Computer vision Students)Colab workshop (for Computer vision Students)
Colab workshop (for Computer vision Students)
Asim Hameed Khan
?
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison Dowdney
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison DowdneySetting up Notifications, Alerts & Webhooks with Flux v2 by Alison Dowdney
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison Dowdney
Weaveworks
?
Webinar - Unbox GitLab CI/CD
Webinar - Unbox GitLab CI/CD Webinar - Unbox GitLab CI/CD
Webinar - Unbox GitLab CI/CD
Annie Huang
?
#Code2Create:: Introduction to App Development in Flutter with Dart
#Code2Create:: Introduction to App Development in Flutter with Dart#Code2Create:: Introduction to App Development in Flutter with Dart
#Code2Create:: Introduction to App Development in Flutter with Dart
GDGKuwaitGoogleDevel
?
DevFest 2022 - GitHub Actions??? ????????? Flutter ???? ???????????
DevFest 2022 - GitHub Actions??? ????????? Flutter ???? ???????????DevFest 2022 - GitHub Actions??? ????????? Flutter ???? ???????????
DevFest 2022 - GitHub Actions??? ????????? Flutter ???? ???????????
SuJang Yang
?
OpenAPI development with Python
OpenAPI development with PythonOpenAPI development with Python
OpenAPI development with Python
Takuro Wada
?
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginGr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Yasuharu Nakano
?
ConcourseCi overview
ConcourseCi  overviewConcourseCi  overview
ConcourseCi overview
Gwenn Etourneau
?
DevOps of Python applications using OpenShift (Italian version)
DevOps of Python applications using OpenShift (Italian version)DevOps of Python applications using OpenShift (Italian version)
DevOps of Python applications using OpenShift (Italian version)
Francesco Fiore
?
MobileConf 2021 ºÝºÝߣs: Let's build macOS CLI Utilities using Swift
MobileConf 2021 ºÝºÝߣs:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 ºÝºÝߣs:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 ºÝºÝߣs: Let's build macOS CLI Utilities using Swift
Diego Freniche Brito
?
CP3108B (Mozilla) Sharing Session on Add-on SDK
CP3108B (Mozilla) Sharing Session on Add-on SDKCP3108B (Mozilla) Sharing Session on Add-on SDK
CP3108B (Mozilla) Sharing Session on Add-on SDK
Mifeng
?
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
 [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
Nexus FrontierTech
?
Why You Should be Using Multi-stage Docker Builds in 2019
Why You Should be Using Multi-stage Docker Builds in 2019Why You Should be Using Multi-stage Docker Builds in 2019
Why You Should be Using Multi-stage Docker Builds in 2019
Codefresh
?
Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024
Henry Schreiner
?
Fullstack workshop
Fullstack workshopFullstack workshop
Fullstack workshop
Assaf Gannon
?
Drone CI/CD Platform
Drone CI/CD PlatformDrone CI/CD Platform
Drone CI/CD Platform
Bo-Yi Wu
?
Life of a Chromium Developer
Life of a Chromium DeveloperLife of a Chromium Developer
Life of a Chromium Developer
mpaproductions
?
Git - Some tips to do it better
Git - Some tips to do it betterGit - Some tips to do it better
Git - Some tips to do it better
Jonas De Smet
?
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
Bo-Yi Wu
?
State ofappdevelopment
State ofappdevelopmentState ofappdevelopment
State ofappdevelopment
gillygize
?
Colab workshop (for Computer vision Students)
Colab workshop (for Computer vision Students)Colab workshop (for Computer vision Students)
Colab workshop (for Computer vision Students)
Asim Hameed Khan
?
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison Dowdney
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison DowdneySetting up Notifications, Alerts & Webhooks with Flux v2 by Alison Dowdney
Setting up Notifications, Alerts & Webhooks with Flux v2 by Alison Dowdney
Weaveworks
?
Webinar - Unbox GitLab CI/CD
Webinar - Unbox GitLab CI/CD Webinar - Unbox GitLab CI/CD
Webinar - Unbox GitLab CI/CD
Annie Huang
?
#Code2Create:: Introduction to App Development in Flutter with Dart
#Code2Create:: Introduction to App Development in Flutter with Dart#Code2Create:: Introduction to App Development in Flutter with Dart
#Code2Create:: Introduction to App Development in Flutter with Dart
GDGKuwaitGoogleDevel
?
DevFest 2022 - GitHub Actions??? ????????? Flutter ???? ???????????
DevFest 2022 - GitHub Actions??? ????????? Flutter ???? ???????????DevFest 2022 - GitHub Actions??? ????????? Flutter ???? ???????????
DevFest 2022 - GitHub Actions??? ????????? Flutter ???? ???????????
SuJang Yang
?
OpenAPI development with Python
OpenAPI development with PythonOpenAPI development with Python
OpenAPI development with Python
Takuro Wada
?
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginGr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Yasuharu Nakano
?
DevOps of Python applications using OpenShift (Italian version)
DevOps of Python applications using OpenShift (Italian version)DevOps of Python applications using OpenShift (Italian version)
DevOps of Python applications using OpenShift (Italian version)
Francesco Fiore
?
MobileConf 2021 ºÝºÝߣs: Let's build macOS CLI Utilities using Swift
MobileConf 2021 ºÝºÝߣs:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 ºÝºÝߣs:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 ºÝºÝߣs: Let's build macOS CLI Utilities using Swift
Diego Freniche Brito
?
CP3108B (Mozilla) Sharing Session on Add-on SDK
CP3108B (Mozilla) Sharing Session on Add-on SDKCP3108B (Mozilla) Sharing Session on Add-on SDK
CP3108B (Mozilla) Sharing Session on Add-on SDK
Mifeng
?
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
 [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
Nexus FrontierTech
?
Why You Should be Using Multi-stage Docker Builds in 2019
Why You Should be Using Multi-stage Docker Builds in 2019Why You Should be Using Multi-stage Docker Builds in 2019
Why You Should be Using Multi-stage Docker Builds in 2019
Codefresh
?
Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024
Henry Schreiner
?

Recently uploaded (20)

People, Process, Technology, Business...
People, Process, Technology, Business...People, Process, Technology, Business...
People, Process, Technology, Business...
annashipman
?
Digital twins as key enabler for innovation in IoT systems
Digital twins as key enabler for innovation in IoT systemsDigital twins as key enabler for innovation in IoT systems
Digital twins as key enabler for innovation in IoT systems
Daniel Lehner
?
Why Ivalua: A Relational Acquisition Model (RAM 2025) Comparison
Why Ivalua: A Relational Acquisition Model (RAM 2025) ComparisonWhy Ivalua: A Relational Acquisition Model (RAM 2025) Comparison
Why Ivalua: A Relational Acquisition Model (RAM 2025) Comparison
Jon Hansen
?
TrustArc Webinar: How to Create a Privacy-First Culture
TrustArc Webinar: How to Create a Privacy-First CultureTrustArc Webinar: How to Create a Privacy-First Culture
TrustArc Webinar: How to Create a Privacy-First Culture
TrustArc
?
What Flow Metrics Teaches Us About Designing Resilient Systems by Mourjo Sen
What Flow Metrics Teaches Us About Designing Resilient Systems by Mourjo SenWhat Flow Metrics Teaches Us About Designing Resilient Systems by Mourjo Sen
What Flow Metrics Teaches Us About Designing Resilient Systems by Mourjo Sen
ScyllaDB
?
Time Travelling at Scale by Richard Hart
Time Travelling at Scale by Richard HartTime Travelling at Scale by Richard Hart
Time Travelling at Scale by Richard Hart
ScyllaDB
?
Ensuring AI Trust and Transparency with Inclusive Design
Ensuring AI Trust and Transparency with Inclusive Design Ensuring AI Trust and Transparency with Inclusive Design
Ensuring AI Trust and Transparency with Inclusive Design
Ted Drake
?
Spin Glass Models of Neural Networks: The Curie-Weiss Model from Statistical ...
Spin Glass Models of Neural Networks: The Curie-Weiss Model from Statistical ...Spin Glass Models of Neural Networks: The Curie-Weiss Model from Statistical ...
Spin Glass Models of Neural Networks: The Curie-Weiss Model from Statistical ...
Charles Martin
?
The 4 Billion Device Future: IoT Insights for Commercial Building Leaders
The 4 Billion Device Future: IoT Insights for Commercial Building LeadersThe 4 Billion Device Future: IoT Insights for Commercial Building Leaders
The 4 Billion Device Future: IoT Insights for Commercial Building Leaders
Memoori
?
AI and developer obsolescence - BCS 2025.pdf
AI and developer obsolescence - BCS 2025.pdfAI and developer obsolescence - BCS 2025.pdf
AI and developer obsolescence - BCS 2025.pdf
Seb Rose
?
Rapid Microbiological Methods in the Pharmaceutical Industry
Rapid Microbiological Methods in the Pharmaceutical IndustryRapid Microbiological Methods in the Pharmaceutical Industry
Rapid Microbiological Methods in the Pharmaceutical Industry
3rania3rania33
?
The Memory Wall in AI - A Crisis We Must Solve
The Memory Wall in AI - A Crisis We Must SolveThe Memory Wall in AI - A Crisis We Must Solve
The Memory Wall in AI - A Crisis We Must Solve
AI Infra Forum
?
Data Intelligence Platform Transforming Data into Actionable Insights.pptx
Data Intelligence Platform Transforming Data into Actionable Insights.pptxData Intelligence Platform Transforming Data into Actionable Insights.pptx
Data Intelligence Platform Transforming Data into Actionable Insights.pptx
Lisa Gerard
?
ScyllaDB: 10 Years and Beyond by Dor Laor
ScyllaDB: 10 Years and Beyond by Dor LaorScyllaDB: 10 Years and Beyond by Dor Laor
ScyllaDB: 10 Years and Beyond by Dor Laor
ScyllaDB
?
How Agoda Scaled 50x Throughput with ScyllaDB by Worakarn Isaratham
How Agoda Scaled 50x Throughput with ScyllaDB by Worakarn IsarathamHow Agoda Scaled 50x Throughput with ScyllaDB by Worakarn Isaratham
How Agoda Scaled 50x Throughput with ScyllaDB by Worakarn Isaratham
ScyllaDB
?
How Natura Uses ScyllaDB and ScyllaDB Connector to Create a Real-time Data Pi...
How Natura Uses ScyllaDB and ScyllaDB Connector to Create a Real-time Data Pi...How Natura Uses ScyllaDB and ScyllaDB Connector to Create a Real-time Data Pi...
How Natura Uses ScyllaDB and ScyllaDB Connector to Create a Real-time Data Pi...
ScyllaDB
?
Verbose AI: The Accessibility Challenge - CSUN 2025
Verbose AI: The Accessibility Challenge - CSUN 2025Verbose AI: The Accessibility Challenge - CSUN 2025
Verbose AI: The Accessibility Challenge - CSUN 2025
Ted Drake
?
Agentic AI in Action: Real-Time Vision, Memory & Autonomy with Browser Use & ...
Agentic AI in Action: Real-Time Vision, Memory & Autonomy with Browser Use & ...Agentic AI in Action: Real-Time Vision, Memory & Autonomy with Browser Use & ...
Agentic AI in Action: Real-Time Vision, Memory & Autonomy with Browser Use & ...
Zilliz
?
Surviving Majority Loss: When a Leader Fails by Konstantin Osipov
Surviving Majority Loss: When a Leader Fails by Konstantin OsipovSurviving Majority Loss: When a Leader Fails by Konstantin Osipov
Surviving Majority Loss: When a Leader Fails by Konstantin Osipov
ScyllaDB
?
March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch Tuesday
Ivanti
?
People, Process, Technology, Business...
People, Process, Technology, Business...People, Process, Technology, Business...
People, Process, Technology, Business...
annashipman
?
Digital twins as key enabler for innovation in IoT systems
Digital twins as key enabler for innovation in IoT systemsDigital twins as key enabler for innovation in IoT systems
Digital twins as key enabler for innovation in IoT systems
Daniel Lehner
?
Why Ivalua: A Relational Acquisition Model (RAM 2025) Comparison
Why Ivalua: A Relational Acquisition Model (RAM 2025) ComparisonWhy Ivalua: A Relational Acquisition Model (RAM 2025) Comparison
Why Ivalua: A Relational Acquisition Model (RAM 2025) Comparison
Jon Hansen
?
TrustArc Webinar: How to Create a Privacy-First Culture
TrustArc Webinar: How to Create a Privacy-First CultureTrustArc Webinar: How to Create a Privacy-First Culture
TrustArc Webinar: How to Create a Privacy-First Culture
TrustArc
?
What Flow Metrics Teaches Us About Designing Resilient Systems by Mourjo Sen
What Flow Metrics Teaches Us About Designing Resilient Systems by Mourjo SenWhat Flow Metrics Teaches Us About Designing Resilient Systems by Mourjo Sen
What Flow Metrics Teaches Us About Designing Resilient Systems by Mourjo Sen
ScyllaDB
?
Time Travelling at Scale by Richard Hart
Time Travelling at Scale by Richard HartTime Travelling at Scale by Richard Hart
Time Travelling at Scale by Richard Hart
ScyllaDB
?
Ensuring AI Trust and Transparency with Inclusive Design
Ensuring AI Trust and Transparency with Inclusive Design Ensuring AI Trust and Transparency with Inclusive Design
Ensuring AI Trust and Transparency with Inclusive Design
Ted Drake
?
Spin Glass Models of Neural Networks: The Curie-Weiss Model from Statistical ...
Spin Glass Models of Neural Networks: The Curie-Weiss Model from Statistical ...Spin Glass Models of Neural Networks: The Curie-Weiss Model from Statistical ...
Spin Glass Models of Neural Networks: The Curie-Weiss Model from Statistical ...
Charles Martin
?
The 4 Billion Device Future: IoT Insights for Commercial Building Leaders
The 4 Billion Device Future: IoT Insights for Commercial Building LeadersThe 4 Billion Device Future: IoT Insights for Commercial Building Leaders
The 4 Billion Device Future: IoT Insights for Commercial Building Leaders
Memoori
?
AI and developer obsolescence - BCS 2025.pdf
AI and developer obsolescence - BCS 2025.pdfAI and developer obsolescence - BCS 2025.pdf
AI and developer obsolescence - BCS 2025.pdf
Seb Rose
?
Rapid Microbiological Methods in the Pharmaceutical Industry
Rapid Microbiological Methods in the Pharmaceutical IndustryRapid Microbiological Methods in the Pharmaceutical Industry
Rapid Microbiological Methods in the Pharmaceutical Industry
3rania3rania33
?
The Memory Wall in AI - A Crisis We Must Solve
The Memory Wall in AI - A Crisis We Must SolveThe Memory Wall in AI - A Crisis We Must Solve
The Memory Wall in AI - A Crisis We Must Solve
AI Infra Forum
?
Data Intelligence Platform Transforming Data into Actionable Insights.pptx
Data Intelligence Platform Transforming Data into Actionable Insights.pptxData Intelligence Platform Transforming Data into Actionable Insights.pptx
Data Intelligence Platform Transforming Data into Actionable Insights.pptx
Lisa Gerard
?
ScyllaDB: 10 Years and Beyond by Dor Laor
ScyllaDB: 10 Years and Beyond by Dor LaorScyllaDB: 10 Years and Beyond by Dor Laor
ScyllaDB: 10 Years and Beyond by Dor Laor
ScyllaDB
?
How Agoda Scaled 50x Throughput with ScyllaDB by Worakarn Isaratham
How Agoda Scaled 50x Throughput with ScyllaDB by Worakarn IsarathamHow Agoda Scaled 50x Throughput with ScyllaDB by Worakarn Isaratham
How Agoda Scaled 50x Throughput with ScyllaDB by Worakarn Isaratham
ScyllaDB
?
How Natura Uses ScyllaDB and ScyllaDB Connector to Create a Real-time Data Pi...
How Natura Uses ScyllaDB and ScyllaDB Connector to Create a Real-time Data Pi...How Natura Uses ScyllaDB and ScyllaDB Connector to Create a Real-time Data Pi...
How Natura Uses ScyllaDB and ScyllaDB Connector to Create a Real-time Data Pi...
ScyllaDB
?
Verbose AI: The Accessibility Challenge - CSUN 2025
Verbose AI: The Accessibility Challenge - CSUN 2025Verbose AI: The Accessibility Challenge - CSUN 2025
Verbose AI: The Accessibility Challenge - CSUN 2025
Ted Drake
?
Agentic AI in Action: Real-Time Vision, Memory & Autonomy with Browser Use & ...
Agentic AI in Action: Real-Time Vision, Memory & Autonomy with Browser Use & ...Agentic AI in Action: Real-Time Vision, Memory & Autonomy with Browser Use & ...
Agentic AI in Action: Real-Time Vision, Memory & Autonomy with Browser Use & ...
Zilliz
?
Surviving Majority Loss: When a Leader Fails by Konstantin Osipov
Surviving Majority Loss: When a Leader Fails by Konstantin OsipovSurviving Majority Loss: When a Leader Fails by Konstantin Osipov
Surviving Majority Loss: When a Leader Fails by Konstantin Osipov
ScyllaDB
?
March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch Tuesday
Ivanti
?

How to build and distribute CLI tool in 15 minutes with Golang

  • 1. How to build and distribute CLI tool in15 Minutes with Golang @kohei_kimura
  • 3. Main Targets ? Beginners ? want to build something with Golang. ? have not used Golang since A Tour of Go.
  • 4. ? I¡¯m not a beginner! ? I¡¯d like to hear stories about parallel processing! Sorry, please install and try stopho, my CLI tool: or go get -d github.com/kohei-kimura/stopho brew tap kohei-kimura/homebrew-stopho brew install stopho
  • 5. stopho ¡ú CLI tool to generate search URLs from stock photos web sites
  • 6. Why CLI tools with Golang?
  • 7. Why CLI tools with Golang? A lot of library for CLI tools Cross compile Not have to write CSS!
  • 8. Building CLI tools is tiresome? ? sub commands ? options ? arguments ? helps ¡­
  • 9. Humanity has urfave/cli Package for building command line apps https://github.com/urfave/cli
  • 10. app.Commands = []cli.Command{ { Name: "search", // Sub command: `stopho search` ShortName: "s", // Alias: `stopho s` Usage: "Generate search URLs from stock photos web sites", Action: command.CmdSearch, Flags: []cli.Flag{ // Options cli.BoolFlag{ // TRUE or FALSE Name: "japan, j", // `stopho s --japan` or `stopho s -j` Usage: "Enable Japan mode", }, cli.StringFlag{ // `stopho s -s $SITE_NAME` Name: "site, s", Usage: "Display only sites matched `value`", }, }, }, }
  • 11. func CmdSearch(c *cli.Context) { // Arguments term := c.Args().Get(0) // Bool Options if c.Bool("japan") { // japan mode } // String Options fmt.Println(c.String("site")) } Function
  • 12. // Set Writer outStream = new(bytes.Buffer) app.Writer = outStream ~~~~~~ // Use `fmt.Fprintf` fmt.Fprintf(c.App.Writer, ...) Testing
  • 13. tcnksm/gcli ? generate CLI skeleton ? urfave/cli and other CLI frameworks
  • 15. Compile by `gox` ? done! ? easy! go get github.com/mitchellh/gox gox
  • 16. GitHub Releases 1. `Releases` tab in repository page 2. `Create a new release` button 3. Upload binary ?les 4. done!
  • 17. Homebew ? ruby script for building apps ? https://github.com/Homebrew/brew/blob/ master/docs/Formula-Cookbook.md $ brew create --set-name $APP_NAME $URL # edit your `$APPNAME.rb`! $ git push
  • 18. Summary Framework: urfave/cli Generator: tcnksm/gcli Compile tool: mitchellh/gox Release platform: GitHub Releases
  • 19. Tips Build a simple and small tool! Refer to famous tools! - e.g. git, docker, ¡­ Provide aliases of subcommands and options! Add GIF animation in README.md Promote on reddit and twitter
  • 21. @kohei_kimura ? IDC Frontier Inc. Developing IoT Platform Back-end on the activity recognition project @kohei_kimura kohei-kimura kohei-kimura.github.io ? Visual Studio Code Kitakyushu -> Yokohama -> Fukuoka
  • 22. IDCF Cloud - One coin IaaS
  • 23. Enjoy your Go programming! Please star my Stopho! -> Please follow me! ->