app

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT Imports: 4 Imported by: 1

README

App

Build Status GoDoc Go Report Card Software License

Wrapper for github.com/urfave/cli/v2

This stable version.

main.go

package main

import (
	"os"
	"github.com/mantyr/app"

	"internal/commands/cli"
	"internal/commands/server"
)

var (
	versionInfo = "dev"
)

func main() {
	app := app.New()
	app.Name = "name"
	app.Usage = "usage"
	app.Version = versionInfo
	app.Description = "description"
	app.Register(
		cli.New(),
		server.New(),
	)
	app.RunAndFatal(os.Args)
}

internal/commands/cli

package cli

import (
	"github.com/mantyr/app"
	"github.com/mantyr/app/commands"

	"internal/commands/cli/item1"
	"internal/commands/cli/item2"
)

type Command struct {
	commands.Command
}

func New() *Command {
	return &Command{}
}

func (c *Command) Init() error {
	c.Command.Name = "cli"
	c.Command.Usage = "Command Line Interface"
	c.Command.Description = "description"
	return nil
}

func (c *Command) Subcommands() []app.Command {
	return []app.Command{
		item1.New(),
		item2.New(),
	}
}

Author

Oleg Shevelev

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(cmd Command) (*cli.Command, error)

Types

type Action

type Action interface {
	Action(ctx *cli.Context) error
}

type App

type App struct {
	Name        string
	Usage       string
	Version     string
	Description string
	// contains filtered or unexported fields
}

func New

func New() *App

func (*App) CLI added in v1.0.1

func (a *App) CLI() *cli.App

func (*App) Register

func (a *App) Register(commands ...Command)

func (*App) RunAndFatal

func (a *App) RunAndFatal(args []string)

type Command

type Command interface {
	Init() error
	GetCommand() commands.Command
}

type Subcommands

type Subcommands interface {
	Subcommands() []Command
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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