cmd

package module
v0.0.0-...-e698a11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2020 License: MIT Imports: 10 Imported by: 0

README

go-cmd

Control application by console.

Install

go get github.com/dainiauskas/go-cmd

Use

import "github.com/dainiauskas/go-cmd"

This gives you access to the go-cmd package.

comm := cmd.New(appName, appDescription, appVersion, appBuild)

// Adding app version show
comm.AddVersion()

// Load configuration from yaml. Configuration name is app_name.yaml
comm.LoadConfig(config)

// Adding service control
comm.AddService(fun() {
  fmt.Println("Servic start")
})

// Start
comm.Execute()
Output
▓█████▄  ██▀███   ▄▄▄       ▄████▄   ▒█████  ▓█████▄ ▓█████
▒██▀ ██▌▓██ ▒ ██▒▒████▄    ▒██▀ ▀█  ▒██▒  ██▒▒██▀ ██▌▓█   ▀
░██   █▌▓██ ░▄█ ▒▒██  ▀█▄  ▒▓█    ▄ ▒██░  ██▒░██   █▌▒███
░▓█▄   ▌▒██▀▀█▄  ░██▄▄▄▄██ ▒▓▓▄ ▄██▒▒██   ██░░▓█▄   ▌▒▓█  ▄
░▒████▓ ░██▓ ▒██▒ ▓█   ▓██▒▒ ▓███▀ ░░ ████▓▒░░▒████▓ ░▒████▒
▒▒▓  ▒ ░ ▒▓ ░▒▓░ ▒▒   ▓▒█░░ ░▒ ▒  ░░ ▒░▒░▒░  ▒▒▓  ▒ ░░ ▒░ ░
░ ▒  ▒   ░▒ ░ ▒░  ▒   ▒▒ ░  ░  ▒     ░ ▒ ▒░  ░ ▒  ▒  ░ ░  ░
░ ░  ░   ░░   ░   ░   ▒   ░        ░ ░ ░ ▒   ░ ░  ░    ░
  ░       ░           ░  ░░ ░          ░ ░     ░       ░  ░
░                         ░                  ░
APP - Aplication description [0.0.0]
https://dracode.xyz

Usage:
  app [command]

Available Commands:
  help        Help about any command
  service     Service control
  version     Print the version number

Flags:
      --config string   configuration file (default "app.yaml")
  -h, --help            help for app
  -v, --verbose         verbose output

Use "app [command] --help" for more information about a command.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CMD

type CMD struct {
	Configuration Configuration
	// contains filtered or unexported fields
}

CMD structore to work with cmd configuration and commands

func New

func New(name, desc, ver, build string) *CMD

New create new root command

func (*CMD) AddService

func (c *CMD) AddService(cb func())

AddService used to install and control services

func (*CMD) AddVersion

func (c *CMD) AddVersion()

AddVersion added to show version command

func (*CMD) Execute

func (c *CMD) Execute() error

Execute used to start using cmd executable

func (*CMD) LoadConfig

func (c *CMD) LoadConfig(cfg Configuration) error

LoadConfig used to read and load configuration file

type Configuration

type Configuration interface {
	GetApp() *config.App
	GetDB() *config.Database
}

type Info

type Info struct {
	Name        string
	Description string
	Version     string
	Build       string
}

Info structure for describe application

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL