Wrapping Up

Powerful Command-Line Applications in Go — by Ricardo Gerardi (71 / 127)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Exercises | TOC | Chapter 7 Using the Cobra CLI Framework 👉

In this chapter, you designed and built a flexible tool that uses other tools and commands to execute specialized tasks in an automated way. You executed external commands, managed their error conditions, captured their output, and handled long-running processes appropriately. You tested your application using two different strategies: using a test helper to build a temporary local infrastructure, and mocking the external command. Finally, you ensured your application handles the operating system signal in a clean way to correctly communicate status to downstream applications and to prevent data loss.

In the next chapter, you’ll use the Cobra CLI framework to help you develop a command-line network port scanner by generating the boilerplate code for the application and handling flags and configuration in a more comprehensive way.

Footnotes

[31] https://pkg.go.dev/errors

[32] https://blog.golang.org/go1.13-errors

[33] https://golang.org/cmd/gofmt/

[34] https://git-scm.com/docs

[35] https://git-scm.com/book/en/v3/Git-on-the-Server-The-Protocols

[36] https://golang.org/src/os/exec/exec_test.go

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.