package
0.0.0-20241203191923-87858b745089
Repository: https://github.com/tarsoqueiroz/aboutgo.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

How to build a CLI tool with Go and Cobra

About

Part I

# Go init
go mod init dadjoke

# Cobra init
~/go/bin/cobra-cli init

# Additional Go struct path
mkdir bin pkg

# First tests
go run main.go 
go run main.go --help
go run main.go -h
go run main.go -v
go run main.go completion bash

# Adding command
~/go/bin/cobra-cli add random

# Second tests
go run main.go -h
go run main.go random -h

# API calls
curl -H "Accept: text/html" https://icanhazdadjoke.com/
curl -H "Accept: text/plain" https://icanhazdadjoke.com/
curl -H "Accept: application/json" https://icanhazdadjoke.com/

# Final test
go run main.go random 
go run main.go random 

Part II

go run main.go random --term=hipster

curl -H "Accept: application/json" "https://icanhazdadjoke.com/search?term=hipster"
curl -H "Accept: application/json" "https://icanhazdadjoke.com/search?term=hipster" | jq .

go run main.go random --term=hipster
go run main.go random --term=apple
go run main.go random --term=tree
go run main.go random --term=ape