Building modern CLI applications in go develop next-level CLIs to improve user experience, increase platform usage, and maximize production

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 asp...

Descripción completa

Detalles Bibliográficos
Autor principal: Montagnino, Marian, author (author)
Otros Autores: Kennedy, William, author (author)
Formato: Libro electrónico
Idioma:Inglés
Publicado: Birmingham, UK : Packt Publishing Ltd [2023]
Edición:1st ed
Materias:
Ver en Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009729739206719
Tabla de Contenidos:
  • 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
  • Summary
  • Questions
  • Answers
  • Further reading
  • Chapter 3: Building an Audio Metadata CLI
  • Technical requirements
  • 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
  • Summary
  • Questions
  • Answers
  • Chapter 4: Popular Frameworks for Building CLIs
  • Technical requirements
  • 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
  • Summary
  • Questions
  • Answers
  • Further reading
  • Part 2: The Ins and Outs of a CLI
  • Chapter 5: Defining the Command-Line Process
  • Technical requirements
  • 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
  • Summary
  • Questions
  • Answers
  • Further reading
  • Chapter 6: Calling External Processes and Handling Errors and Timeouts
  • Technical requirements
  • 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
  • Summary
  • Questions
  • Answers
  • Further reading
  • Chapter 7: Developing for Different Platforms
  • Technical requirements
  • 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
  • Summary
  • Questions
  • Answers
  • Further reading
  • Part 3: Interactivity and Empathic Driven Design.
  • Chapter 8: Building for Humans versus Machines
  • Technical requirements
  • 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
  • Summary
  • Questions
  • Further reading
  • Answers
  • Chapter 9: The Empathic Side of Development
  • Technical requirements
  • 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
  • Summary
  • Questions
  • Further reading
  • Answers
  • Chapter 10: Interactivity with Prompts and Terminal Dashboards
  • Technical requirements
  • 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
  • Summary
  • Questions
  • Answers
  • Further reading
  • Part 4: Building and Distributing for Different Platforms
  • Chapter 11: Custom Builds and Testing CLI Commands
  • Technical requirements
  • 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
  • Summary
  • Questions
  • Answers
  • Further reading
  • Chapter 12: Cross-Compilation across Different Platforms
  • Technical requirements
  • 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
  • Summary
  • Questions
  • Answers
  • Further reading
  • 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
  • Summary
  • Questions
  • Further reading
  • Answers
  • Chapter 14: Publishing Your Go Binary as a Homebrew Formula with GoReleaser
  • Technical requirements
  • GoReleaser workflow
  • Defining the workflow
  • Trigger release
  • Tag and push the code
  • Installing with Homebrew and Testing
  • Summary
  • Questions
  • Further reading.
  • Answers
  • Index
  • About Packt
  • Other Books You May Enjoy.