### Install blackfriday-tool command-line utility Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/russross/blackfriday/v2/README.md This command installs `blackfriday-tool`, a simple command-line utility that serves as a complete example of how to use the Blackfriday library. It will also install Blackfriday itself if not already present. ```Go go get github.com/russross/blackfriday-tool ``` -------------------------------- ### Install terminfo Go Package Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/xo/terminfo/README.md This snippet demonstrates how to install the `terminfo` Go package using the `go get` command. It fetches the package from its GitHub repository and installs it into your Go workspace, making it available for your projects. ```Shell $ go get -u github.com/xo/terminfo ``` -------------------------------- ### Install Viper Go Library Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/viper/README.md Instructions to install the Viper Go configuration library using the `go get` command. Viper uses Go Modules to manage its dependencies. ```shell go get github.com/spf13/viper ``` -------------------------------- ### CLI Option: Display Help for Install Command Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_monarx_install.md Provides detailed help information for the `hapi vps monarx install` command. This option outlines its usage, available parameters, and examples to assist users. ```Shell -h, --help help for install ``` -------------------------------- ### Install and Test pflag Go Package Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/pflag/README.md Instructions for installing the pflag library using `go get` and running its tests using `go test`. ```Go go get github.com/spf13/pflag go test github.com/spf13/pflag ``` -------------------------------- ### Install AtomicGo Cursor Package Source: https://github.com/hostinger/api-cli/blob/main/vendor/atomicgo.dev/cursor/README.md Use the `go get` command to download and install the `atomicgo.dev/cursor` package into your Go project. ```Shell go get atomicgo.dev/cursor ``` -------------------------------- ### Install tml CLI Tool Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/liamg/tml/README.md Instructions for installing the tml standalone binary. It provides commands for Go 1.16+ using `go install` and for Go <1.16 using `go get -u`. Users should ensure `$GOPATH/bin` is in their system's `$PATH` for the binary to be accessible. ```Bash # For Go 1.16+ # Make sure that `$GOPATH/bin` is in your `$PATH`, because that's where this gets installed go install github.com/liamg/tml/tml@latest # For Go <1.16 go get -u github.com/liamg/tml/tml ``` -------------------------------- ### Install and Use go-jsonmerge Command-line Tool Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/apapsch/go-jsonmerge/v2/README.md Instructions for installing the `jsonmerge` command-line utility and basic usage examples, including how to get help and merge multiple JSON files. ```bash $ go get -u github.com/RaveNoX/go-jsonmerge/cmd/jsonmerge $ jsonmerge [options] ... # For help $ jsonmerge -h ``` -------------------------------- ### Install Afero Go Library Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/afero/README.md Instructions to install the Afero library using the Go package manager. ```Go go get github.com/spf13/afero ``` -------------------------------- ### APIDOC: hapi vps vm start Command Options Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_vm_start.md Documents the specific options available for the `hapi vps vm start` command, including both direct command options and those inherited from its parent commands. These options control behavior such as displaying help, specifying configuration files, and defining output formats. ```APIDOC Options: -h, --help: help for start Options inherited from parent commands: --config string: Config file (default is $HOME/.hapi.yaml) --format string: Output format type (json|table|tree), default: table ``` -------------------------------- ### Go PTerm Demo Application Setup and Utilities Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/pterm/pterm/README.md Initial setup for the PTerm demo application, including flag parsing for speedup and intro skipping, and defining a list of pseudo-programs for demonstration purposes. It also includes the main function's initial setup calls. ```go package main import ( "flag" "math/rand" "reflect" "strconv" "strings" "time" "github.com/pterm/pterm" "github.com/pterm/pterm/putils" ) // Speed the demo up, by setting this flag. // Usefull for debugging. // Example: // // go run main.go -speedup var speedup = flag.Bool("speedup", false, "Speed up the demo") var skipIntro = flag.Bool("skip-intro", false, "Skips the intro") var second = time.Second var pseudoProgramList = strings.Split("pseudo-excel pseudo-photoshop pseudo-chrome pseudo-outlook pseudo-explorer "+ "pseudo-git pseudo-vsc pseudo-intellij pseudo-minecraft pseudo-scoop pseudo-chocolatey", " ") func main() { setup() // Setup the demo (flags etc.) // Show intro if !*skipIntro { introScreen() clear() } ``` -------------------------------- ### CLI: Start Hostinger VPS Virtual Machine Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_vm_start.md Provides the command-line syntax to start a virtual machine using the `hapi` CLI tool. It requires the virtual machine ID and supports optional flags. ```CLI hapi vps vm start [flags] ``` -------------------------------- ### Install and Use tomll CLI Tool Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/pelletier/go-toml/v2/README.md Instructions to install the `tomll` command-line tool using `go install` and how to display its help message. This tool lints and reformats TOML files. ```Shell $ go install github.com/pelletier/go-toml/v2/cmd/tomll@latest $ tomll --help ``` -------------------------------- ### Install conc Go Library Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/sourcegraph/conc/README.md Command to install the `conc` Go library using `go get`. ```sh go get github.com/sourcegraph/conc ``` -------------------------------- ### Install Blackfriday v2 using go get Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/russross/blackfriday/v2/README.md This command downloads and installs the Blackfriday v2 package into your current Go development module. It's the recommended way to get the latest version. ```Go go get github.com/russross/blackfriday/v2 ``` -------------------------------- ### CLI Usage: hapi vps recovery start Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_recovery_start.md Example command to initiate recovery mode for a virtual machine, specifying the virtual machine ID and optional flags. ```shell hapi vps recovery start [flags] ``` -------------------------------- ### Install and Use jsontoml CLI Tool Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/pelletier/go-toml/v2/README.md Instructions to install the `jsontoml` command-line tool using `go install` and how to display its help message. This tool converts JSON files to TOML. ```Shell $ go install github.com/pelletier/go-toml/v2/cmd/jsontoml@latest $ jsontoml --help ``` -------------------------------- ### CLI Options: hapi vps recovery start Command Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_recovery_start.md Detailed documentation for command-specific options and inherited options available for the 'hapi vps recovery start' command, including help, temporary root password, config file, and output format. ```APIDOC Options: -h, --help help for start --password string Temporary root password for recovery mode Options inherited from parent commands: --config string Config file (default is $HOME/.hapi.yaml) --format string Output format type (json|table|tree), default: table ``` -------------------------------- ### Install and Use tomljson CLI Tool Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/pelletier/go-toml/v2/README.md Instructions to install the `tomljson` command-line tool using `go install` and how to display its help message. This tool converts TOML files to JSON. ```Shell $ go install github.com/pelletier/go-toml/v2/cmd/tomljson@latest $ tomljson --help ``` -------------------------------- ### Install Go YAML v3 Package Source: https://github.com/hostinger/api-cli/blob/main/vendor/gopkg.in/yaml.v3/README.md Use the `go get` command to download and install the `gopkg.in/yaml.v3` package into your Go module cache. ```Shell go get gopkg.in/yaml.v3 ``` -------------------------------- ### Install go.uber.org/atomic Go module Source: https://github.com/hostinger/api-cli/blob/main/vendor/go.uber.org/atomic/README.md Command to install the `go.uber.org/atomic` package at version 1 using `go get`. This is the recommended way to add the dependency to your Go project. ```shell $ go get -u go.uber.org/atomic@v1 ``` -------------------------------- ### Go PTerm: Setup Function for Animation Speed Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/pterm/pterm/README.md This `setup` function parses command-line flags. If the `speedup` flag is set, it reduces the `second` variable's value to 200 milliseconds, effectively speeding up animations or delays used throughout the PTerm examples. ```Go func setup() { flag.Parse() if *speedup { second = time.Millisecond * 200 } } ``` -------------------------------- ### CLI Command Options: Get VPS Post-Install Script Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_post-install-scripts_get.md Defines the command-specific options available for the 'get' operation, such as the help flag. ```APIDOC -h, --help help for get ``` -------------------------------- ### Markdown Definition List Syntax Example Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/russross/blackfriday/v2/README.md Example of creating a definition list using Markdown syntax supported by Blackfriday. ```Markdown Cat : Fluffy animal everyone likes Internet : Vector of transmission for pictures of cats ``` -------------------------------- ### Install locafero Go library Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/sagikazarmark/locafero/README.md Installs the locafero library for Afero using the Go module system. This command fetches the latest version of the library and adds it to your project's dependencies. ```shell go get github.com/sagikazarmark/locafero ``` -------------------------------- ### Install mapstructure Go Library Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/go-viper/mapstructure/v2/README.md This command installs the `mapstructure` library for Go projects using `go get`. It fetches the latest version of the library from its GitHub repository, making it available for use in your Go applications. ```shell go get github.com/go-viper/mapstructure/v2 ``` -------------------------------- ### Install Go uniseg Package Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/rivo/uniseg/README.md This `go get` command installs the `github.com/rivo/uniseg` package, enabling Unicode text segmentation functionalities in your Go projects. It fetches the package and its dependencies, making them available for import. ```bash go get github.com/rivo/uniseg ``` -------------------------------- ### Markdown Table Syntax Example Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/russross/blackfriday/v2/README.md Example of creating a table using Markdown syntax supported by Blackfriday. ```Markdown Name | Age --------|------ Bob | 27 Alice | 23 ``` -------------------------------- ### Install AtomicGo Keyboard Go Package Source: https://github.com/hostinger/api-cli/blob/main/vendor/atomicgo.dev/keyboard/README.md This snippet provides the command to install the AtomicGo keyboard package using the Go module system. It fetches the necessary dependencies and makes the package available for use in Go projects. ```Go go get atomicgo.dev/keyboard ``` -------------------------------- ### Install Cobra Go Library Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/cobra/README.md This command uses `go get` to download and install the latest version of the Cobra library into your Go workspace. It's the first step to incorporating Cobra into your Go project. ```Go go get -u github.com/spf13/cobra@latest ``` -------------------------------- ### Install Go UUID Package Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/google/uuid/README.md Installs the `github.com/google/uuid` package using the Go package manager. ```Shell go get github.com/google/uuid ``` -------------------------------- ### Markdown Footnote Syntax Example Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/russross/blackfriday/v2/README.md Example of creating a footnote using Markdown syntax supported by Blackfriday. ```Markdown This is a footnote.[^1] [^1]: the footnote text. ``` -------------------------------- ### CLI Command Options: hapi vps actions get Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_actions_get.md Lists specific options available for the `hapi vps actions get` command. ```APIDOC -h, --help help for get ``` -------------------------------- ### CLI Options: Get Command Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_templates_get.md Lists command-specific options for the 'hapi vps templates get' command. ```APIDOC -h, --help help for get ``` -------------------------------- ### CLI Command Inherited Options: Hostinger API Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_post-install-scripts_get.md Describes global options passed down from parent commands, including configuration file path and output format preferences. ```APIDOC --config string Config file (default is $HOME/.hapi.yaml) --format string Output format type (json|table|tree), default: table ``` -------------------------------- ### Build and Initialize go-jsonmerge Development Environment Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/apapsch/go-jsonmerge/v2/README.md Commands to set up the development environment and build the `go-jsonmerge` project, including dependency installation and compilation steps. ```bash # Install depencencies ./init.sh # Build ./build.sh ``` -------------------------------- ### Example JSON Configuration with Nested Keys Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/viper/README.md This JSON snippet provides an example configuration structure featuring deeply nested keys. It demonstrates how host and port settings can be organized hierarchically for different services like 'metric' and 'warehouse' within a 'datastore' section, which is then used to illustrate Viper's nested key access. ```json { "host": { "address": "localhost", "port": 5799 }, "datastore": { "metric": { "host": "127.0.0.1", "port": 3099 }, "warehouse": { "host": "198.0.0.1", "port": 2112 } } } ``` -------------------------------- ### Go: Template for a LivePrinter Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/pterm/pterm/CONTRIBUTING.md Presents a template for a `LivePrinter` in Go, which is used for dynamic, live output. It includes `Start` to initialize the printer and `Stop` to terminate it. `GenericStart` and `GenericStop` are provided for interface compatibility. ```Go // Start the TemplatePrinter. package pterm import "github.com/pterm/pterm" type TemplatePrinter struct{ } func (s TemplatePrinter) Start(text...any) (*TemplatePrinter, error) { // TODO: Replace Template with actual printer. // TODO: start logic return &s, nil } // Stop terminates the TemplatePrinter immediately. // The TemplatePrinter will not resolve into anything. func (s *TemplatePrinter) Stop() error { // TODO: stop logic return nil } // GenericStart runs Start, but returns a LivePrinter. // This is used for the interface LivePrinter. // You most likely want to use Start instead of this in your program. func (s *TemplatePrinter) GenericStart() (*LivePrinter, error) { _, err := s.Start() lp := LivePrinter(s) return &lp, err } // GenericStop runs Stop, but returns a LivePrinter. // This is used for the interface LivePrinter. // You most likely want to use Stop instead of this in your program. func (s *TemplatePrinter) GenericStop() (*LivePrinter, error) { err := s.Stop() lp := LivePrinter(s) return &lp, err } ``` -------------------------------- ### CLI Command Synopsis: Get VPS Post-Install Script Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_post-install-scripts_get.md Illustrates the command-line interface syntax for retrieving a specific post-install script by its ID, including optional flags. ```APIDOC hapi vps post-install-scripts get [flags] ``` -------------------------------- ### APIDOC: hapi vps snapshots get Command Options Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_snapshots_get.md Details the available command-line options for the `hapi vps snapshots get` command, including both direct and inherited flags, specifying their purpose and default values. ```APIDOC hapi vps snapshots get: Options: -h, --help: help for get Inherited Options: --config string: Config file (default is $HOME/.hapi.yaml) --format string: Output format type (json|table|tree), default: table ``` -------------------------------- ### Go: Testing WithXxx() Methods for Printers Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/pterm/pterm/CONTRIBUTING.md Provides examples of how to test `WithXxx()` methods for printers. These tests verify that `With` methods correctly create a new printer instance and set the specified value, ensuring immutability and proper configuration. ```Go func TestSectionPrinter_WithStyle(t *testing.T) { p := SectionPrinter{} s := NewStyle(FgRed, BgRed, Bold) p2 := p.WithStyle(s) assert.Equal(t, s, p2.Style) assert.Empty(t, p.Style) } func TestSectionPrinter_WithTopPadding(t *testing.T) { p := SectionPrinter{} p2 := p.WithTopPadding(1337) assert.Equal(t, 1337, p2.TopPadding) assert.Empty(t, p.TopPadding) } ``` -------------------------------- ### Initializing Afero OsFs Backend Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/afero/README.md Shows how to initialize 'OsFs', Afero's wrapper around native operating system file calls. This backend allows your application to interact directly with the host's file system, making it trivial to switch between real and mock file systems as needed. ```go appfs := afero.NewOsFs() appfs.MkdirAll("src/a", 0755) ``` -------------------------------- ### Install and Use Crypt CLI for K/V Store Configuration Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/viper/README.md This snippet provides commands to install the `crypt` command-line helper and use it to set and retrieve configuration values in a Key/Value store like etcd. `crypt` is used by Viper for remote configuration. ```Bash $ go get github.com/sagikazarmark/crypt/bin/crypt $ crypt set -plaintext /config/hugo.json /Users/hugo/settings/config.json ``` ```Bash $ crypt get -plaintext /config/hugo.json ``` -------------------------------- ### Go PTerm Progress Bar Demonstration Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/pterm/pterm/README.md Illustrates the creation and usage of a PTerm progress bar to show installation progress for a list of pseudo-programs, including updating the title and handling success/warning messages. ```go showcase("Progress bar", 2, func() { pb, _ := pterm.DefaultProgressbar.WithTotal(len(pseudoProgramList)).WithTitle("Installing stuff").Start() for i := 0; i < pb.Total; i++ { pb.UpdateTitle("Installing " + pseudoProgramList[i]) if pseudoProgramList[i] == "pseudo-minecraft" { pterm.Warning.Println("Could not install pseudo-minecraft\nThe company policy forbids games.") } else { pterm.Success.Println("Installing " + pseudoProgramList[i]) } pb.Increment() time.Sleep(second / 2) } pb.Stop() }) ``` -------------------------------- ### Go PTerm Table Rendering Example Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/pterm/pterm/README.md Illustrates how to create and render both standard and boxed tables using PTerm, demonstrating header support and centering the output. ```go showcase("Tables", 4, func() { for i := 0; i < 3; i++ { pterm.Println() } td := [][]string{ {"Library", "Description"}, {"PTerm", "Make beautiful CLIs"}, {"Testza", "Programmer friendly test framework"}, {"Cursor", "Move the cursor around the terminal"}, } table, _ := pterm.DefaultTable.WithHasHeader().WithData(td).Srender() boxedTable, _ := pterm.DefaultTable.WithHasHeader().WithData(td).WithBoxed().Srender() pterm.DefaultCenter.Println(table) pterm.DefaultCenter.Println(boxedTable) }) ``` -------------------------------- ### CLI Options: hapi vps ptr create Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_ptr_create.md Lists the command-specific options available for `hapi vps ptr create`, such as the help flag, which provides usage information. ```Shell -h, --help help for create ``` -------------------------------- ### Initializing Afero MemMapFs Backend Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/afero/README.md Demonstrates the initialization of 'MemMapFs', Afero's fully atomic memory-backed file system. This backend is ideal for mocking and speeding up I/O operations where persistence is not required, and it is safe for concurrent use within goroutines. ```go mm := afero.NewMemMapFs() mm.MkdirAll("src/a", 0755) ``` -------------------------------- ### API Documentation: hapi vps post-install-scripts create Options Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_post-install-scripts_create.md Details the specific command-line options available when creating a new post-install script, including parameters for script content, name, and displaying help information. ```APIDOC Option: --content Type: string Description: Post-install script content Option: -h, --help Description: help for create Option: --name Type: string Description: Post-install script name ``` -------------------------------- ### Declare Afero Filesystem Backend in Go Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/afero/README.md Demonstrates how to declare a package variable for an Afero filesystem, showing examples for an in-memory filesystem (MemMapFs) and an OS-backed filesystem (OsFs). ```Go var AppFs = afero.NewMemMapFs() or var AppFs = afero.NewOsFs() ``` -------------------------------- ### Main Application Logic for terminfo Example Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/xo/terminfo/README.md This Go `main` function demonstrates the core usage of the `terminfo` package. It loads terminal capabilities, initializes the terminal, sets a title, prints colored characters, and waits for a Ctrl-C signal to gracefully exit, ensuring terminal cleanup. ```Go // _examples/simple/main.go package main import ( "bytes" "fmt" "log" "os" "os/signal" "strings" "sync" "syscall" "github.com/xo/terminfo" ) func main() { //r := rand.New(nil) // load terminfo ti, err := terminfo.LoadFromEnv() if err != nil { log.Fatal(err) } // cleanup defer func() { err := recover() termreset(ti) if err != nil { log.Fatal(err) } }() terminit(ti) termtitle(ti, "simple example!") termputs(ti, 3, 3, "Ctrl-C to exit") maxColors := termcolors(ti) if maxColors > 256 { maxColors = 256 } for i := 0; i < maxColors; i++ { termputs(ti, 5+i/16, 5+i%16, ti.Colorf(i, 0, "█")) } // wait for signal sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) <-sigs } ``` -------------------------------- ### API Documentation: hapi vps Inherited Options Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_post-install-scripts_create.md Describes common command-line options inherited from parent commands, applicable across hapi vps commands. These include specifying a configuration file and defining the output format. ```APIDOC Option: --config Type: string Description: Config file (default is $HOME/.hapi.yaml) Option: --format Type: string Description: Output format type (json|table|tree), default: table ``` -------------------------------- ### CLI Options for hapi vps post-install-scripts Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_post-install-scripts.md Displays help information for the `hapi vps post-install-scripts` command. This option provides details on how to use the specific command and its available sub-commands. ```CLI -h, --help help for post-install-scripts ``` -------------------------------- ### CLI Options for hapi vps snapshots Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_snapshots.md Displays help information for the `hapi vps snapshots` command. ```CLI -h, --help help for snapshots ``` -------------------------------- ### Install Cobra CLI Generator Tool Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/cobra/README.md The `cobra-cli` tool is a command-line program that helps scaffold new Cobra applications and command files, accelerating development. Use `go install` to get the latest version of this generator. ```Go go install github.com/spf13/cobra-cli@latest ``` -------------------------------- ### Bind an Entire PFlag Set to Viper Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/viper/README.md This example demonstrates how to bind an entire `pflag.FlagSet` to Viper. After defining and parsing flags, `viper.BindPFlags(pflag.CommandLine)` is used to make all defined flags accessible through Viper's `Get` methods, centralizing configuration retrieval. ```Go pflag.Int("flagname", 1234, "help message for flagname") pflag.Parse() viper.BindPFlags(pflag.CommandLine) i := viper.GetInt("flagname") // retrieve values from viper instead of pflag ``` -------------------------------- ### Apply 256-Color Foreground and Background Styles in Go Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/gookit/color/README.md Provides examples of using `color.C256` to set 256-color foreground and background styles. It shows how to create a color object and apply it to messages using `Println` and `Printf`. ```go c := color.C256(132) // fg color c.Println("message") c.Printf("format %s", "message") c := color.C256(132, true) // bg color c.Println("message") c.Printf("format %s", "message") ``` -------------------------------- ### CLI Options: Inherited from Parent Commands Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_monarx_install.md These are common command-line options inherited from parent commands, allowing users to specify a configuration file path or define the output format for command results, such as JSON, table, or tree. ```Shell --config string Config file (default is $HOME/.hapi.yaml) --format string Output format type (json|table|tree), default: table ``` -------------------------------- ### CLI Command: Install Monarx Malware Scanner Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_monarx_install.md The primary command to install the Monarx malware scanner on a specified virtual machine. It requires the virtual machine's ID as an argument to target the installation correctly. ```Shell hapi vps monarx install [flags] ``` -------------------------------- ### Migrate Go OS Package Calls to Afero Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/afero/README.md Illustrates how to replace standard 'os' package file operations with Afero's 'AppFs' methods for consistent filesystem interaction. ```Go os.Open("/tmp/foo") We would replace it with: AppFs.Open("/tmp/foo") ``` -------------------------------- ### API Endpoint: Monarx Malware Scanner Installation Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_monarx_install.md Describes the purpose and functionality of the `hapi vps monarx install` endpoint, which enables the installation of the Monarx malware scanner for enhanced virtual machine security against malicious software. ```APIDOC Endpoint: hapi vps monarx install Purpose: Installs the Monarx malware scanner on a specified virtual machine. Description: Monarx is a security tool designed to detect and prevent malware infections on virtual machines. By installing Monarx, users can enhance the security of their virtual machines, ensuring that they are protected against malicious software. ``` -------------------------------- ### Run Local Go Documentation Server Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/pflag/README.md This command launches a local web server that hosts Go package documentation, including the `pflag` package. Users can then access the documentation by navigating to the specified localhost address in their browser. This requires the Go toolchain to be installed. ```Shell godoc -http=:6060 ``` -------------------------------- ### CLI Options: Inherited from Parent Commands Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_snapshots_create.md Common options inherited from parent commands that can be used with `hapi vps snapshots create`, including configuration file path and output format. ```APIDOC Options inherited from parent commands: --config string Config file (default is $HOME/.hapi.yaml) --format string Output format type (json|table|tree), default: table ``` -------------------------------- ### APIDOC: hapi vps post-install-scripts list Command Options Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_post-install-scripts_list.md This section documents the available command-line options for the `hapi vps post-install-scripts list` command. It includes both options specific to this command (like pagination) and those inherited from parent commands (like configuration file path and output format). ```APIDOC Options: -h, --help help for list --page int Page number (default 1) Options inherited from parent commands: --config string Config file (default is $HOME/.hapi.yaml) --format string Output format type (json|table|tree), default: table ``` -------------------------------- ### CLI: hapi VPS Firewall Get Command Options Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_firewall_get.md Available options for the `hapi vps firewall get` command, including help and inherited parent command options for configuration and output formatting. ```Shell -h, --help help for get --config string Config file (default is $HOME/.hapi.yaml) --format string Output format type (json|table|tree), default: table ``` -------------------------------- ### CLI Command Usage: hapi vps actions get Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_actions_get.md Shows the basic syntax for the `hapi vps actions get` command, requiring a virtual machine ID and an action ID, with optional flags. ```CLI hapi vps actions get [flags] ``` -------------------------------- ### Move Cursor to Start of Line (Go) Source: https://github.com/hostinger/api-cli/blob/main/vendor/atomicgo.dev/cursor/README.md Moves the cursor to the start of the current line. ```Go func StartOfLine() ``` -------------------------------- ### CLI Command Usage for hapi vps post-install-scripts create Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_post-install-scripts_create.md Shows the basic command-line syntax for creating a new post-install script, indicating that it accepts various flags. ```Bash hapi vps post-install-scripts create [flags] ``` -------------------------------- ### Demonstrate Go CLI Color Library Usage Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/gookit/color/README.md This Go example showcases various methods to apply colors and styles to command-line output using the `gookit/color` library. It demonstrates direct color functions, `fmt`-like methods, custom style creation, and HTML tag-style rendering for flexible text styling. ```go package main import ( "fmt" "github.com/gookit/color" ) func main() { // quick use package func color.Redp("Simple to use color") color.Redln("Simple to use color") color.Greenp("Simple to use color\n") color.Cyanln("Simple to use color") color.Yellowln("Simple to use color") // quick use like fmt.Print* color.Red.Println("Simple to use color") color.Green.Print("Simple to use color\n") color.Cyan.Printf("Simple to use %s\n", "color") color.Yellow.Printf("Simple to use %s\n", "color") // use like func red := color.FgRed.Render green := color.FgGreen.Render fmt.Printf("%s line %s library\n", red("Command"), green("color")) // custom color color.New(color.FgWhite, color.BgBlack).Println("custom color style") // can also: color.Style{color.FgCyan, color.OpBold}.Println("custom color style") // internal theme/style: color.Info.Tips("message") color.Info.Prompt("message") color.Info.Println("message") color.Warn.Println("message") color.Error.Println("message") // use style tag color.Print("hello, welcome\n") // Custom label attr: Supports the use of 16 color names, 256 color values, rgb color values and hex color values color.Println("hello, welcome") // apply a style tag color.Tag("info").Println("info style text") // prompt message color.Info.Prompt("prompt style message") color.Warn.Prompt("prompt style message") // tips message color.Info.Tips("tips style message") color.Warn.Tips("tips style message") } ``` -------------------------------- ### CLI Options for hapi vps backups Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_backups.md Lists the command-line options specific to the `hapi vps backups` command, including the help flag. ```cli -h, --help help for backups ``` -------------------------------- ### hapi vps vm get Command Options Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_vm_get.md This section details the command-specific options for 'hapi vps vm get', including the help flag, and inherited options from parent commands for configuration file path and output format. ```APIDOC Options: -h, --help help for get Options inherited from parent commands: --config string Config file (default is $HOME/.hapi.yaml) --format string Output format type (json|table|tree), default: table ``` -------------------------------- ### CLI Options: Create Command Specific Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_snapshots_create.md Specific options available for the `hapi vps snapshots create` command, primarily for displaying help information. ```APIDOC Options: -h, --help help for create ``` -------------------------------- ### Move Area Cursor to Start of Line (Go) Source: https://github.com/hostinger/api-cli/blob/main/vendor/atomicgo.dev/cursor/README.md Moves the cursor within the Area to the start of the current line. ```Go func (area *Area) StartOfLine() ``` -------------------------------- ### Move Cursor to Start of Line Up (Go) Source: https://github.com/hostinger/api-cli/blob/main/vendor/atomicgo.dev/cursor/README.md Moves the cursor up by n lines, then moves the cursor to the start of the line. ```Go func StartOfLineUp(n int) ``` -------------------------------- ### Move Cursor to Start of Line Down (Go) Source: https://github.com/hostinger/api-cli/blob/main/vendor/atomicgo.dev/cursor/README.md Moves the cursor down by n lines, then moves the cursor to the start of the line. ```Go func StartOfLineDown(n int) ``` -------------------------------- ### CLI Options for hapi vps data-centers Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_data-centers.md Lists command-line options specific to the `hapi vps data-centers` command, including the help flag. ```APIDOC -h, --help help for data-centers ``` -------------------------------- ### hapi vps vm get Command Usage Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_vm_get.md This snippet shows the basic syntax for using the 'hapi vps vm get' command to retrieve information about a specific virtual machine. It requires the virtual machine ID as a mandatory argument. ```APIDOC hapi vps vm get [flags] ``` -------------------------------- ### Install Go multierr Package Source: https://github.com/hostinger/api-cli/blob/main/vendor/go.uber.org/multierr/README.md This command installs the `go.uber.org/multierr` package, allowing you to use its functionalities for combining multiple Go errors in your projects. ```Shell go get -u go.uber.org/multierr ``` -------------------------------- ### Create and Render a Basic Table in Go Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/aquasecurity/table/README.md Demonstrates the basic usage of the `table` Go module to create and render a simple table with headers and rows to standard output. The output shows a fully bordered table with row lines. Output: ┌────┬─────────────┬────────┐ │ ID │ Fruit │ Stock │ ├────┼─────────────┼────────┤ │ 1 │ Apple │ 14 │ ├────┼─────────────┼────────┤ │ 2 │ Banana │ 88,041 │ ├────┼─────────────┼────────┤ │ 3 │ Cherry │ 342 │ ├────┼─────────────┼────────┤ │ 4 │ Dragonfruit │ 1 │ └────┴─────────────┴────────┘ ```go package main import ( "os" "github.com/aquasecurity/table" ) func main() { t := table.New(os.Stdout) t.SetHeaders("ID", "Fruit", "Stock") t.AddRow("1", "Apple", "14") t.AddRow("2", "Banana", "88,041") t.AddRow("3", "Cherry", "342") t.AddRow("4", "Dragonfruit", "1") t.Render() } ``` -------------------------------- ### Install Go CLI Color Library Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/gookit/color/README.md This command installs the `gookit/color` library into your Go project, making it available for use in your applications. ```bash go get github.com/gookit/color ``` -------------------------------- ### Afero File System Methods API Reference Source: https://github.com/hostinger/api-cli/blob/main/vendor/github.com/spf13/afero/README.md Comprehensive list of methods available on Afero filesystem objects, detailing their parameters and return types. ```APIDOC Chmod(name string, mode os.FileMode) : error Chown(name string, uid, gid int) : error Chtimes(name string, atime time.Time, mtime time.Time) : error Create(name string) : File, error Mkdir(name string, perm os.FileMode) : error MkdirAll(path string, perm os.FileMode) : error Name() : string Open(name string) : File, error OpenFile(name string, flag int, perm os.FileMode) : File, error Remove(name string) : error RemoveAll(path string) : error Rename(oldname, newname string) : error Stat(name string) : os.FileInfo, error ``` -------------------------------- ### CLI Inherited Options: hapi vps ptr Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_ptr_create.md Details the options inherited from parent commands, applicable to `hapi vps ptr create`. These options include specifying a configuration file and defining the output format for command results. ```Shell --config string Config file (default is $HOME/.hapi.yaml) --format string Output format type (json|table|tree), default: table ``` -------------------------------- ### CLI Usage: Get VPS Template Details Source: https://github.com/hostinger/api-cli/blob/main/docs/hapi_vps_templates_get.md Shows the basic command-line syntax for retrieving details of a specific OS template using its ID. ```bash hapi vps templates get