Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyCLI

A simple command-line application built with Go and Cobra.

Installation

# Clone the repository
git clone https://github.com/jbrinkman/MyCli.git
cd MyCli

# Build the application
go build -o mycli

# Optionally, install it to your GOPATH/bin
go install

Usage

Basic Command

# Run the base command
./mycli

Version Command

# Display version information
./mycli version

Echo Command

# Echo text to the console
./mycli echo Hello, World!

# Echo text in uppercase
./mycli echo --uppercase Hello, World!

Global Flags

# Enable verbose output
./mycli --verbose

# Get help
./mycli --help

Development

Adding New Commands

To add a new command:

  1. Create a new file in the cmd directory
  2. Define your command using the Cobra framework
  3. Add it to the root command in the init() function

Example:

package cmd

import (
    "fmt"
    "github.com/spf13/cobra"
)

var newCmd = &cobra.Command{
    Use:   "new",
    Short: "A brief description",
    Long:  `A longer description`,
    Run: func(cmd *cobra.Command, args []string) {
        fmt.Println("New command executed")
    },
}

func init() {
    RootCmd.AddCommand(newCmd)
}

License

MIT

About

A simple command-line application built with Go and Cobra

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages