cmd

package
v0.0.0-...-3f45c39 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdConfig = cli.Command{
	Name:   "config",
	Usage:  "Create a new configuration file",
	Action: runConfig,
}

CmdConfig represents a command-line command which create a new configuration file.

View Source
var CmdManage = cli.Command{
	Name:   "manage",
	Usage:  "Manage active projects",
	Action: runManage,
	Subcommands: []cli.Command{
		{
			Name:    "add",
			Usage:   "Add a project to the active projects list.",
			Aliases: []string{"a"},
			Action: func(c *cli.Context) error {
				settings.LoadActiveProjs(true)
				proj, err := getProjectFromString(c.Args().First())
				if err != nil {
					fmt.Printf("Failed to parse project: %s\n", err)
					os.Exit(2)
				}
				if exists, _ := settings.IsActiveProject(proj.Namespace, proj.Project); !exists {
					settings.ActiveProjs.Projects = append(settings.ActiveProjs.Projects, *proj)
					settings.SaveActiveProjs()
					fmt.Printf("Project added to list!\n")
				} else {
					fmt.Printf("Project is already included in list!\n")
					os.Exit(1)
				}
				return nil
			},
		},
		{
			Name:    "remove",
			Aliases: []string{"rm", "del", "delete"},
			Usage:   "Remove a project from the active projects list.",
			Action: func(c *cli.Context) error {
				settings.LoadActiveProjs(true)
				proj, err := getProjectFromString(c.Args().First())
				if err != nil {
					fmt.Printf("Failed to parse project: %s\n", err)
					os.Exit(2)
				}
				if exists, id := settings.IsActiveProject(proj.Namespace, proj.Project); exists {
					settings.ActiveProjs.Projects = remove(settings.ActiveProjs.Projects, id)
					settings.SaveActiveProjs()
					fmt.Printf("Project removed from list!\n")
				} else {
					fmt.Printf("Project is not included in the list!\n")
					os.Exit(1)
				}
				return nil
			},
		},
	},
}

CmdManage represents a command-line command which manages the list of active projects.

View Source
var CmdStart = cli.Command{
	Name:    "run",
	Aliases: []string{"start", "web"},
	Flags: []cli.Flag{
		cli.BoolFlag{Name: "no-web", Usage: "Does not run the web server"},
	},
	Usage:  "Start the learning bot",
	Action: start,
}

CmdStart represents a command-line command which starts the bot.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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