My Account Log in

2 options

Building modern CLI applications in go : develop next-level CLIs to improve user experience, increase platform usage, and maximize production / Marian Montagnino and William Kennedy.

Ebook Central College Complete Available online

View online

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Montagnino, Marian, Author.
Kennedy, William, author.
Language:
English
Subjects (All):
Application software--Development.
Application software.
Go (Computer program language).
Physical Description:
1 online resource (406 pages)
Edition:
1st ed.
Place of Publication:
Birmingham, UK : Packt Publishing Ltd, [2023]
Biography/History:
Montagnino Marian: Marian Montagnino is a Senior Software Engineer at Netflix with over 20 years of experience. Since the early nineties, when her family first got a home computer, she has been using the terminal and command line applications to navigate through text based systems. In 1995, she held her first job as a SysOp, or system operator, for Real of Mirage BBS in Fair Lawn, NJ. Her early years discovering technology inspired her to continue learning about computers. She received her Dual Computer Science and Mathematics of Operations Research BSc from Rensselaer Polytechnic Institute and her Applied Mathematics MSc from Stevens Institute of Technology.
Summary:
Evolve the humble CLI using Go and unleash the next generation of powerful, flexible, and empathy-driven interfaces Purchase of the print or Kindle book includes a free PDF eBook Key Features Discover how Go enables the development of elegant and intuitive CLIs Explore a range of CLI development aspects and pick up a vast array of best practices Create engaging and user-friendly interfaces and learn how to distribute them Book Description Although graphical user interfaces (GUIs) are intuitive and user-friendly, nothing beats a command-line interface (CLI) when it comes to productivity. Many organizations settle for a GUI without searching for alternatives that offer better accessibility and functionality. If this describes your organization, then pick up this book and get them to rethink that decision. Building Modern CLI Applications in Go will help you achieve an interface that rivals a GUI in elegance yet surpasses it in high-performance execution. Through its practical, step-by-step approach, you'll learn everything you need to harness the power and simplicity of the Go language to build CLI applications that revolutionize the way you work. After a primer on CLI standards and Go, you'll be launched into tool design and proper framework use for true development proficiency. The book then moves on to all things CLI, helping you master everything from arguments and flags to errors and API calls. Later, you'll dive into the nuances of empathic development so that you can ensure the best UX possible, before you finish up with build tags, cross-compilation, and container-based distribution. By the end of this UX book, you'll be fully equipped to take the performance and flexibility of your organization's applications to the next level. What you will learn Master the Go code structure, testing, and other essentials Add a colorful dashboard to your CLI using engaging ASCII banners Use Cobra, Viper, and other frameworks to give your CLI an edge Handle inputs, API commands, errors, and timeouts like a pro Target builds for specific platforms the right way using build tags Build with empathy, using easy bug submission and traceback Containerize, distribute, and publish your CLIs quickly and easily Who this book is for This book is for beginner- and intermediate-level Golang developers who take an interest in developing CLIs and enjoy learning by doing. You'll need an understanding of basic Golang programming concepts, but will require no prior knowledge of CLI design and development. This book helps you join a community of CLI developers and distribute within the popular Homebrew package management tool.
Contents:
Intro
Preface
Title Page
Copyright
Dedication
Contributors
Table of Contents
Part 1: Getting Started with a Solid Foundation
Chapter 1: Understanding CLI Standards
A brief introduction and history of the command line
About the history
Introducing the CLI
The philosophy of CLI development
Checklist for a successful CLI
The guidelines
Name
Help and documentation
Input
Output
Configuration
Security
Open source community
Software lifespan and robustness
Go for CLIs
Summary
Questions
Answers
Further reading
Chapter 2: Structuring Go Code for CLI Applications
Technical requirements
Commonly used program layouts for robust applications
Program layouts
Common folders
Determining use cases and requirements
Use cases
Requirements
Disadvantages and benefits of use cases and requirements
Use cases, diagrams, and requirements for a CLI
Requirements for a metadata CLI
Structuring an audio metadata CLI application
Bounded context
Language
Entities and value objects
Aggregation
Service
Events
Repository
Creating the structure
Chapter 3: Building an Audio Metadata CLI
Defining the components
cmd/
cmd/api/
cmd/cli/
cmd/cli/command
extractors/
extractors/tags
extractors/transcript
internal/interfaces
models/
services/metadata
storage/
vendor/
Implementing use cases
Uploading audio
Requesting metadata
Testing a CLI
Manual testing
Testing and mocking
Chapter 4: Popular Frameworks for Building CLIs
Cobra - a library for building modern CLI applications
Creating subcommands
Global, local, and required flags.
Intelligent suggestions
Automatically generated help and man pages
Powering your CLI
Viper - easy configuration for CLIs
Configuration types
Watching for live config changes
Basic calculator CLI using Cobra and Viper
The Cobra CLI commands
The Viper configuration
Running the basic calculator
Part 2: The Ins and Outs of a CLI
Chapter 5: Defining the Command-Line Process
Receiving the input and user interaction
Defining subcommands, arguments, and flags
Piping
Signals and control characters
User interaction
Processing data
Returning the resulting output and defining best practices
Chapter 6: Calling External Processes and Handling Errors and Timeouts
Calling external processes
The os/exec package
Creating commands using the Cmd struct
Running the command
Interacting with REST APIs
Get request
Pagination
Rate limiting
Handling the expected - timeouts and errors
Timeouts with external command processes
Errors or panics with external command processes
Timeouts and other errors with HTTP requests
Chapter 7: Developing for Different Platforms
Packages for platform-independent functionality
The os package
The time package
The path package
The runtime package
Implementing independent or platform-specific code
Platform-independent code
Platform-specific code
Build tags for targeted platforms
The build package
Build tags
OS-level differences
Part 3: Interactivity and Empathic Driven Design.
Chapter 8: Building for Humans versus Machines
Building for humans versus machines
Is it a TTY?
Designing for a machine
Designing for a human
Increasing information density with ASCII art
Displaying information with tables
Clarifying with emojis
Using color with intention
Spinners and progress bars
Disabling colors
Being consistent across CLIs
Naming
Positional versus flag arguments
Flag naming
Usage
Chapter 9: The Empathic Side of Development
Rewriting errors to be human-readable
Guidelines for writing error messages
Decorating errors
Customizing errors
Writing better error messages
Providing debug and traceback information
Logging data
Initiating a logger
Implementing a logger
Trying out verbose mode to view stack traces
Effortless bug submission
Help, documentation, and support
Generating help text
Generating man pages
Embedding empathy into your documentation
Chapter 10: Interactivity with Prompts and Terminal Dashboards
Guiding users with prompts
Designing a useful terminal dashboard
Learning about Termdash
Implementing a terminal dashboard
Creating the terminal layer
Creating the infrastructure layer
Creating the container layer
Creating the widgets layer
Part 4: Building and Distributing for Different Platforms
Chapter 11: Custom Builds and Testing CLI Commands
What are build tags and how can you use them?
How to utilize build tags
Creating a pro, free, and dev version
Adding build tags to enable pprof
Building with tags.
Building a free version
Building a pro version
Building to enable pprof on the pro version
Testing CLI commands
Mocking the HTTP client
Handling test configuration
Creating a test for a command
Running the tests
Chapter 12: Cross-Compilation across Different Platforms
Manual compilation versus build automation tools
Using GOOS and GOARCH
Compiling for Linux, macOS, and Windows
Building using tags
Building using the GOOS environment variable
Building using the GOARCH environment variable
Installing using tags and GOOS env va
Installing using tags and GOARCH env var
Scripting to compile for multiple platforms
Creating a bash script to compile in Darwin or Linux
Creating a PowerShell script in Windows
Chapter 13: Using Containers for Distribution
Technical requirement
Why use containers?
Benefiting from containers
Deciding not to use containers
Building a simple Docker image
Running a simple Docker container
Testing with containers
Creating the integration test file
Writing the integration tests
Writing the Dockerfiles
Distributing with containers
Building a new image to run as an executable
Interacting with your container as an executable
Mapping host machine to container file paths
Reducing image size by using multi-stage builds
Distributing your Docker image
Depending on Docker
Chapter 14: Publishing Your Go Binary as a Homebrew Formula with GoReleaser
GoReleaser workflow
Defining the workflow
Trigger release
Tag and push the code
Installing with Homebrew and Testing
Further reading.
Answers
Index
About Packt
Other Books You May Enjoy.
Notes:
Description based on print version record.
ISBN:
9781804613696
180461369X
OCLC:
1372368643

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

Find

Home Release notes

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Find catalog Using Articles+ Using your account