commands

package
v0.0.0-...-1ce83d5 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AliasCommand = cli.Command{
	Name:      "alias",
	Usage:     "Add a Bash alias for the script",
	ArgsUsage: "ALIAS",
	Action: func(c *cli.Context) error {
		if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
			fmt.Println("Unsupported OS")
			return nil
		}

		if c.NArg() != 1 {
			fmt.Println("an alias should be specified")
			return nil
		}

		err := autocomplete.AddAliasWithBashAutoComplete(c.Args()[0])
		if err != nil {
			fmt.Println(err)
			return nil
		}

		fmt.Println("Please, restart your terminal session to use the new alias")
		return nil
	},
}
View Source
var ArchiveCommand = cli.Command{
	Name:      "archive",
	Usage:     "Archive stories before a certain date",
	ArgsUsage: "YYYY-MM-DD",
	Action: func(c *cli.Context) error {
		if err := checkIsBacklogDirectory(); err != nil {
			fmt.Println(err)
			return nil
		}

		if c.NArg() != 1 {
			fmt.Println("A date should be specified")
			return nil
		}

		beforeDate, err := time.Parse("2006-1-2", c.Args()[0])
		if err != nil {
			fmt.Println("Invalid date. Should be in YYYY-MM-DD format.")
			return nil
		}

		backlogDir, _ := filepath.Abs(".")
		action := actions.NewArchiveAction(backlogDir, beforeDate)
		return action.Execute()
	},
}
View Source
var AssignUserCommand = cli.Command{
	Name:      "assign",
	Usage:     "Assign a story to a user",
	ArgsUsage: " ",
	Flags: []cli.Flag{
		cli.StringFlag{
			Name:  "s",
			Usage: fmt.Sprintf("Status - %s", backlog.AllStatusesList()),
		},
	},
	Action: func(c *cli.Context) error {
		statusCode := c.String("s")

		if statusCode == "" {
			fmt.Println("-s option is required")
			return nil
		}
		if !backlog.IsValidStatusCode(statusCode) {
			fmt.Printf("illegal status: %s\n", statusCode)
			return nil
		}
		if err := checkIsBacklogDirectory(); err != nil {
			fmt.Println(err)
			return nil
		}
		backlogDir, _ := filepath.Abs(".")

		action := actions.NewAssignUserAction(backlogDir, statusCode)
		return action.Execute()
	},
}
View Source
var ChangeStatusCommand = cli.Command{
	Name:      "change-status",
	Usage:     "Change story status",
	ArgsUsage: " ",
	Flags: []cli.Flag{
		cli.StringFlag{
			Name:  "s",
			Usage: fmt.Sprintf("Status - %s", backlog.AllStatusesList()),
		},
	},
	Action: func(c *cli.Context) error {
		statusCode := c.String("s")
		if statusCode == "" {
			fmt.Println("-s option is required")
			return nil
		}

		if err := checkIsBacklogDirectory(); err != nil {
			fmt.Println(err)
			return nil
		}
		backlogDir, _ := filepath.Abs(".")

		action := actions.NewChangeStatusAction(backlogDir, statusCode)
		return action.Execute()
	},
}
View Source
var ChangeTagCommand = cli.Command{
	Name:      "change-tag",
	Usage:     "Change a tag",
	ArgsUsage: "OLD_TAG NEW_TAG",
	Action: func(c *cli.Context) error {
		if c.NArg() != 2 {
			fmt.Println("old and new tags should be specified")
			return nil
		}

		rootDir, _ := filepath.Abs(".")
		if err := checkIsBacklogDirectory(); err == nil {
			rootDir = filepath.Dir(rootDir)
		} else if err := checkIsRootDirectory("."); err != nil {
			return err
		}

		oldTag := strings.ToLower(c.Args()[0])
		newTag := strings.ToLower(c.Args()[1])

		action := actions.NewChangeTagAction(rootDir, oldTag, newTag)
		return action.Execute()
	},
}
View Source
var ChangeUserCommand = cli.Command{
	Name:      "change-user",
	Usage:     "Change the user",
	ArgsUsage: "OLD-USER NEW-USER",
	Action: func(c *cli.Context) error {
		if len(c.Args()) < 2 {
			fmt.Println("Name, email or prefix of both users should be specified")
			return nil
		}
		if len(c.Args()) > 2 {
			fmt.Println("Only two (2) arguments are allowed")
			return nil
		}
		fromNameOrEmail, toNameOrEmail := c.Args()[0], c.Args()[1]

		rootDir, err := findRootDirectory()
		if err != nil {
			return err
		}

		action := actions.NewChangeUserAction(rootDir, fromNameOrEmail, toNameOrEmail)
		return action.Execute()
	},
}
View Source
var CreateBacklogCommand = cli.Command{
	Name:      "create-backlog",
	Usage:     "Create a new backlog",
	ArgsUsage: "BACKLOG_NAME",
	Action: func(c *cli.Context) error {
		if err := checkIsRootDirectory("."); err != nil {
			out, statusErr := git.Status()
			if statusErr != nil && strings.Contains(out, "fatal: not a git repository") {
				err := git.Init()
				if err != nil {
					return err
				}
				err = AddConfigAndGitIgnore(backlog.NewBacklogsStructure("."))
				if err != nil {
					return err
				}
			} else {
				return err
			}
		}

		if c.NArg() == 0 {
			fmt.Println("A backlog name should be specified")
			return nil
		}

		backlogName := strings.Join(c.Args(), " ")

		action := actions.NewCreateBacklogAction(".", backlogName)
		return action.Execute()
	},
}
View Source
var CreateIdeaCommand = cli.Command{
	Name:      "create-idea",
	Usage:     "Create a new idea",
	ArgsUsage: "IDEA_TITLE",
	Flags: []cli.Flag{
		cli.BoolFlag{
			Name:   "simulate",
			Hidden: true,
		},
		cli.StringFlag{
			Name:   "user",
			Hidden: true,
		},
	},
	Action: func(c *cli.Context) error {
		simulate := c.Bool("simulate")
		user := c.String("user")

		rootDir, err := findRootDirectory()
		if err != nil {
			return err
		}

		if c.NArg() == 0 {
			if !simulate {
				fmt.Println("an idea name should be specified")
			}
			return nil
		}

		ideaTitle := strings.Join(c.Args(), " ")
		action := actions.NewCreateIdeaAction(rootDir, ideaTitle, user, simulate)
		return action.Execute()
	},
}
View Source
var CreateItemCommand = cli.Command{
	Name:      "create-item",
	Usage:     "Create a new item for the backlog",
	ArgsUsage: "ITEM_NAME",
	Flags: []cli.Flag{
		cli.BoolFlag{
			Name:   "simulate",
			Hidden: true,
		},
		cli.StringFlag{
			Name:   "user",
			Hidden: true,
		},
	},
	Action: func(c *cli.Context) error {
		simulate := c.Bool("simulate")
		user := c.String("user")

		if err := checkIsBacklogDirectory(); err != nil {
			fmt.Println(err)
			return nil
		}
		if c.NArg() == 0 {
			if !simulate {
				fmt.Println("an item name should be specified")
			}
			return nil
		}
		itemTitle := strings.Join(c.Args(), " ")
		action := actions.NewCreateItemAction(".", itemTitle, user, simulate)
		return action.Execute()
	},
}
View Source
var CreateUserCommand = cli.Command{
	Name:      "create-user",
	Usage:     "Create a new user",
	ArgsUsage: "NAME EMAIL",
	Flags: []cli.Flag{
		cli.StringFlag{
			Name:   "name",
			Hidden: true,
		},
		cli.StringFlag{
			Name:   "email",
			Hidden: true,
		},
	},
	Action: func(c *cli.Context) error {
		name := c.String("name")
		email := c.String("email")
		parts := c.Args()

		rootDir, err := findRootDirectory()
		if err != nil {
			return err
		}
		action := actions.NewCreateUserAction(rootDir, name, email, parts)
		return action.Execute()
	},
}
View Source
var DeleteTagCommand = cli.Command{
	Name:      "delete-tag",
	Usage:     "Delete a tag",
	ArgsUsage: "TAG",
	Action: func(c *cli.Context) error {
		if c.NArg() != 1 {
			fmt.Println("a tag should be specified")
			return nil
		}

		rootDir, err := findRootDirectory()
		if err != nil {
			return err
		}

		tag := strings.ToLower(c.Args()[0])
		action := actions.NewDeleteTagAction(rootDir, tag)
		return action.Execute()
	},
}
View Source
var DeleteUserCommand = cli.Command{
	Name:      "delete-user",
	Usage:     "Delete the user",
	ArgsUsage: "USER",
	Action: func(c *cli.Context) error {
		if len(c.Args()) == 0 {
			fmt.Println("User name, email or prefix should be specified")
			return nil
		}
		nameOrEmail := strings.Join(c.Args(), " ")

		rootDir, err := findRootDirectory()
		if err != nil {
			return err
		}

		action := actions.NewDeleteUserAction(rootDir, nameOrEmail)
		return action.Execute()
	},
}
View Source
var ImportCommand = cli.Command{
	Name:      "import",
	Usage:     "Import an existing Pivotal Tracker story",
	ArgsUsage: "CSV_FILE",
	Action: func(c *cli.Context) error {
		if err := checkIsBacklogDirectory(); err != nil {
			fmt.Println(err)
			return nil
		}
		if c.NArg() == 0 {
			fmt.Println("a csv file should be specified")
			return nil
		}

		action := actions.NewImportAction(".", c.Args())
		return action.Execute()
	},
}
View Source
var PointsCommand = cli.Command{
	Name:      "points",
	Usage:     "Show total points by user and status",
	ArgsUsage: " ",
	Flags: []cli.Flag{
		cli.StringFlag{
			Name:  "u",
			Usage: "User Name",
		},
		cli.StringFlag{
			Name:  "s",
			Usage: fmt.Sprintf("Status - %s", backlog.AllStatusesList()),
			Value: backlog.DoingStatus.Code,
		},
	},
	Action: func(c *cli.Context) error {
		user := c.String("u")
		statusCode := c.String("s")

		if err := checkIsBacklogDirectory(); err != nil {
			fmt.Println(err)
			return nil
		}

		action := actions.NewPointsAction(".", statusCode, user)
		return action.Execute()
	},
}
View Source
var TimelineCommand = cli.Command{
	Name:      "timeline",
	Usage:     "Build a new timeline",
	ArgsUsage: "TAG",
	Action: func(c *cli.Context) error {
		if c.NArg() != 1 {
			fmt.Println("a tag should be specified")
			return nil
		}

		rootDir, err := findRootDirectory()
		if err != nil {
			return err
		}

		tag := strings.ToLower(c.Args()[0])
		action := actions.NewTimelineAction(rootDir, tag)
		return action.Execute()
	},
}
View Source
var VelocityCommand = cli.Command{
	Name:      "velocity",
	Usage:     "Show the velocity of a backlog over time",
	ArgsUsage: "NUMBER_OF_WEEKS",
	Action: func(c *cli.Context) error {
		if err := checkIsBacklogDirectory(); err != nil {
			fmt.Println(err)
			return nil
		}

		var weekCount int
		if c.NArg() > 0 {
			weekCount, _ = strconv.Atoi(c.Args()[0])
		}
		if weekCount <= 0 {
			weekCount = 12
		}

		action := actions.NewVelocityAction(".", weekCount)
		return action.Execute()
	},
}
View Source
var WorkCommand = cli.Command{
	Name:      "work",
	Usage:     "Show user work by status",
	ArgsUsage: " ",
	Flags: []cli.Flag{
		cli.StringFlag{
			Name:  "u",
			Usage: "User Name",
		},
		cli.StringFlag{
			Name:  "s",
			Usage: fmt.Sprintf("Status - %s", backlog.AllStatusesList()),
		},
		cli.StringFlag{
			Name:  "t",
			Usage: "List of Tags",
		},
	},
	Action: func(c *cli.Context) error {
		if err := checkIsBacklogDirectory(); err != nil {
			fmt.Println(err)
			return nil
		}
		backlogDir, _ := filepath.Abs(".")

		user := c.String("u")
		statusCode := c.String("s")
		tags := c.String("t")

		if c.NArg() > 0 {
			fmt.Printf("illegal arguments: %s\n", strings.Join(c.Args(), " "))
			return nil
		}

		action := actions.NewWorkAction(backlogDir, statusCode, user, tags)
		return action.Execute()
	},
}

Functions

func AddConfigAndGitIgnore

func AddConfigAndGitIgnore(root *backlog.BacklogsStructure) error

func NewSyncCommand

func NewSyncCommand() cli.Command

Types

This section is empty.

Jump to

Keyboard shortcuts

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