added doing

initial version with completions missing
This commit is contained in:
rsteube 2024-04-10 13:49:45 +02:00
parent b4dc9ba8ec
commit bb0f260e02
28 changed files with 662 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var initCmd = &cobra.Command{
Use: "doing init [OPTIONS] [REFERENCE_ISSUE]",
Short: "Create a .doing-cli-config file",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(initCmd).Standalone()
initCmd.Flags().Bool("help", false, "Show this message and exit.")
rootCmd.AddCommand(initCmd)
// TODO positional completion
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var issueCmd = &cobra.Command{
Use: "issue [OPTIONS] COMMAND [ARGS]...",
Short: "Work with issues",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(issueCmd).Standalone()
issueCmd.Flags().Bool("help", false, "Show this message and exit.")
rootCmd.AddCommand(issueCmd)
}

View File

@ -0,0 +1,21 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var issue_closeCmd = &cobra.Command{
Use: "close [OPTIONS] WORK_ITEM_ID...",
Short: "Close a specific WORK_ITEM_ID",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(issue_closeCmd).Standalone()
issue_closeCmd.Flags().Bool("help", false, "Show this message and exit.")
issueCmd.AddCommand(issue_closeCmd)
// TODO positional completion
}

View File

@ -0,0 +1,42 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/doing"
"github.com/spf13/cobra"
)
var issue_createCmd = &cobra.Command{
Use: "create [OPTIONS] ISSUE",
Short: "Create an issue",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(issue_createCmd).Standalone()
issue_createCmd.Flags().Bool("add-to-current-sprint", false, "If the item needs to be added to the current sprint")
issue_createCmd.Flags().StringP("assignee", "a", "", "Emailadres or alias of person to assign")
issue_createCmd.Flags().StringP("body", "b", "", "Optional description of the work item")
issue_createCmd.Flags().Bool("do-not-add-to-current-sprint", false, "If the item needs to be added to the current sprint")
issue_createCmd.Flags().Bool("help", false, "Show this message and exit")
issue_createCmd.Flags().StringP("label", "l", "", "Attach tags (labels) to work item")
issue_createCmd.Flags().BoolP("mine", "m", false, "Assign issue to yourself")
issue_createCmd.Flags().Bool("not-mine", false, "Do not assign issue to yourself")
issue_createCmd.Flags().StringP("parent", "p", "", "To create a child work item, specify the ID of the parent work item")
issue_createCmd.Flags().StringP("story_points", "s", "", "The number of story points to assign assigned if not specified")
issue_createCmd.Flags().StringP("type", "t", "", "Type of work item")
issueCmd.AddCommand(issue_createCmd)
// TODO completion
carapace.Gen(issue_createCmd).FlagCompletion(carapace.ActionMap{
"assignee": carapace.ActionValues("@me"),
"body": carapace.ActionValues(),
"label": carapace.ActionValues(),
"parent": carapace.ActionValues(),
"story_points": carapace.ActionValues(),
"type": doing.ActionWorkItemTypes(),
})
// TODO positional completion
}

View File

@ -0,0 +1,43 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/doing"
"github.com/spf13/cobra"
)
var issue_listCmd = &cobra.Command{
Use: "list [OPTIONS]",
Short: "List issues related to the project",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(issue_listCmd).Standalone()
issue_listCmd.Flags().StringP("assignee", "a", "", "Filter by assignee")
issue_listCmd.Flags().StringP("author", "A", "", "Filter by author")
issue_listCmd.Flags().Bool("help", false, "Show this message and exit")
issue_listCmd.Flags().StringP("label", "l", "", "Filter by labels")
issue_listCmd.Flags().Bool("no-show_state", false, "Do not show column with work item state")
issue_listCmd.Flags().Bool("no-web", false, "Open overview of issues in the web browser")
issue_listCmd.Flags().StringP("output_format", "o", "", "Output format")
issue_listCmd.Flags().Bool("show_state", false, "Show column with work item state")
issue_listCmd.Flags().StringP("state", "s", "", "Filter by state")
issue_listCmd.Flags().String("story_points", "", "Filter on number of story points")
issue_listCmd.Flags().StringP("type", "t", "", "Type of work item")
issue_listCmd.Flags().BoolP("web", "w", false, "Open overview of issues in the web browser")
issueCmd.AddCommand(issue_listCmd)
// TODO completion
carapace.Gen(issue_listCmd).FlagCompletion(carapace.ActionMap{
"assignee": carapace.ActionValues(),
"author": carapace.ActionValues(),
"label": carapace.ActionValues(),
"output_format": carapace.ActionValues("table", "array"),
"state": carapace.ActionValues(),
"story_points": carapace.ActionValues(),
"type": doing.ActionWorkItemTypes(),
})
}

View File

@ -0,0 +1,39 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/doing"
"github.com/carapace-sh/carapace/pkg/style"
"github.com/spf13/cobra"
)
var listCmd = &cobra.Command{
Use: "list [OPTIONS]",
Short: "List issues related to the project",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(listCmd).Standalone()
listCmd.Flags().StringP("assignee", "a", "", "Filter by assignee")
listCmd.Flags().StringP("author", "A", "", "Filter by author")
listCmd.Flags().Bool("help", false, "Show this message and exit")
listCmd.Flags().StringP("label", "l", "", "Filter by labels")
listCmd.Flags().StringP("output_format", "o", "", "Output format")
listCmd.Flags().StringP("state", "s", "", "Filter by state")
listCmd.Flags().String("story_points", "", "Filter on number of story points")
listCmd.Flags().StringP("type", "t", "", "Type of work item")
rootCmd.AddCommand(listCmd)
// TODO completion
carapace.Gen(listCmd).FlagCompletion(carapace.ActionMap{
"assignee": carapace.ActionValues(),
"author": carapace.ActionValues(),
"label": carapace.ActionValues(),
"output_format": carapace.ActionValues("table", "array"),
"state": carapace.ActionValues("open", "closed", "all").StyleF(style.ForKeyword), // TODO custom states
"story_points": carapace.ActionValues(),
"type": doing.ActionWorkItemTypes(),
})
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var openCmd = &cobra.Command{
Use: "open [OPTIONS] COMMAND [ARGS]...",
Short: "Quickly open certain links",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(openCmd).Standalone()
openCmd.Flags().Bool("help", false, "Show this message and exit.")
rootCmd.AddCommand(openCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var open_boardCmd = &cobra.Command{
Use: "board",
Short: "Open board view",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(open_boardCmd).Standalone()
open_boardCmd.Flags().Bool("help", false, "Show this message and exit.")
openCmd.AddCommand(open_boardCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var open_branchCmd = &cobra.Command{
Use: "branch",
Short: "Open a specific BRANCH_NAME",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(open_branchCmd).Standalone()
open_branchCmd.Flags().Bool("help", false, "Show this message and exit.")
openCmd.AddCommand(open_branchCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var open_branchesCmd = &cobra.Command{
Use: "branches",
Short: "Open an overview of the repositories' branches",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(open_branchesCmd).Standalone()
open_branchesCmd.Flags().Bool("help", false, "Show this message and exit.")
openCmd.AddCommand(open_branchesCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var open_issueCmd = &cobra.Command{
Use: "issue",
Short: "Open a specific WORK_ITEM_ID",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(open_issueCmd).Standalone()
open_issueCmd.Flags().Bool("help", false, "Show this message and exit.")
openCmd.AddCommand(open_issueCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var open_issuesCmd = &cobra.Command{
Use: "issues",
Short: "Open all active issues view",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(open_issuesCmd).Standalone()
open_issuesCmd.Flags().Bool("help", false, "Show this message and exit.")
openCmd.AddCommand(open_issuesCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var open_pipeCmd = &cobra.Command{
Use: "pipe",
Short: "Open latest pipeline runs for repository view",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(open_pipeCmd).Standalone()
open_pipeCmd.Flags().Bool("help", false, "Show this message and exit.")
openCmd.AddCommand(open_pipeCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var open_policiesCmd = &cobra.Command{
Use: "policies",
Short: "Will show the default branch policies by default",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(open_policiesCmd).Standalone()
open_policiesCmd.Flags().Bool("help", false, "Show this message and exit.")
openCmd.AddCommand(open_policiesCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var open_prCmd = &cobra.Command{
Use: "pr",
Short: "Open a specific PULLREQUEST_ID",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(open_prCmd).Standalone()
open_prCmd.Flags().Bool("help", false, "Show this message and exit.")
openCmd.AddCommand(open_prCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var open_prsCmd = &cobra.Command{
Use: "prs",
Short: "Open active PRs for repository view",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(open_prsCmd).Standalone()
open_prsCmd.Flags().Bool("help", false, "Show this message and exit.")
openCmd.AddCommand(open_prsCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var open_repoCmd = &cobra.Command{
Use: "repo",
Short: "Open repository view",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(open_repoCmd).Standalone()
open_repoCmd.Flags().Bool("help", false, "Show this message and exit.")
openCmd.AddCommand(open_repoCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var open_sprintCmd = &cobra.Command{
Use: "sprint",
Short: "Open current sprint view",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(open_sprintCmd).Standalone()
open_sprintCmd.Flags().Bool("help", false, "Show this message and exit.")
openCmd.AddCommand(open_sprintCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var prCmd = &cobra.Command{
Use: "pr [OPTIONS] COMMAND [ARGS]...",
Short: "Work with pull requests",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(prCmd).Standalone()
prCmd.Flags().Bool("help", false, "Show this message and exit.")
rootCmd.AddCommand(prCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var pr_checkoutCmd = &cobra.Command{
Use: "checkout [OPTIONS] PR_ID",
Short: "Check out a pull request in git",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(pr_checkoutCmd).Standalone()
pr_checkoutCmd.Flags().Bool("help", false, "Show this message and exit.")
prCmd.AddCommand(pr_checkoutCmd)
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var pr_closeCmd = &cobra.Command{
Use: "close [OPTIONS] PR_ID...",
Short: "Close a specific PR_ID",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(pr_closeCmd).Standalone()
pr_closeCmd.Flags().Bool("help", false, "Show this message and exit.")
prCmd.AddCommand(pr_closeCmd)
}

View File

@ -0,0 +1,43 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/git"
"github.com/spf13/cobra"
)
var pr_createCmd = &cobra.Command{
Use: "create [OPTIONS] WORK_ITEM_ID",
Short: "Create a pull request from a work item ID",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(pr_createCmd).Standalone()
pr_createCmd.Flags().Bool("auto-complete", false, "Set the PR to complete autom. when all policies have passed")
pr_createCmd.Flags().String("branch-prefix", "", "The prefix to be prepended to the branch name")
pr_createCmd.Flags().Bool("checkout", false, "Run git commands to checkout remote branch locally")
pr_createCmd.Flags().StringP("default-branch", "b", "", "The name of the branch to branch from and to")
pr_createCmd.Flags().Bool("delete-source-branch", false, "Set to delete source branch when pull request completes")
pr_createCmd.Flags().Bool("draft", false, "Create draft/WIP pull request")
pr_createCmd.Flags().Bool("help", false, "Show this message and exit")
pr_createCmd.Flags().Bool("no-auto-complete", false, "Set the PR to complete autom. when all policies have passed")
pr_createCmd.Flags().Bool("no-checkout", false, "Do not run git commands to checkout remote branch locally")
pr_createCmd.Flags().Bool("no-delete-source-branch", false, "Set to delete source branch when pull request completes")
pr_createCmd.Flags().Bool("no-draft", false, "Do not create draft/WIP pull request")
pr_createCmd.Flags().Bool("no-self-approve", false, "Do not add yourself as reviewer and add your approval")
pr_createCmd.Flags().Bool("no-web", false, "Open newly created issue in the web browser")
pr_createCmd.Flags().StringP("reviewers", "r", "", "Space separated list of reviewer emails or aliases")
pr_createCmd.Flags().Bool("self-approve", false, "Add yourself as reviewer and add your approval")
pr_createCmd.Flags().BoolP("web", "w", false, "Open newly created issue in the web browser")
prCmd.AddCommand(pr_createCmd)
carapace.Gen(pr_createCmd).FlagCompletion(carapace.ActionMap{
"branch-prefix": carapace.ActionValues(),
"default-branch": git.ActionRefs(git.RefOption{LocalBranches: true, RemoteBranches: true}), // TODO test
"reviewers": carapace.ActionValues(),
})
// TODO positional completion
}

View File

@ -0,0 +1,33 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var pr_listCmd = &cobra.Command{
Use: "list [OPTIONS]",
Short: "List pull requests related to the project",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(pr_listCmd).Standalone()
pr_listCmd.Flags().StringP("assignee", "a", "", "Filter by assigned reviewers")
pr_listCmd.Flags().Bool("help", false, "Show this message and exit")
pr_listCmd.Flags().StringP("label", "l", "", "Filter by labels")
pr_listCmd.Flags().StringP("limit", "L", "", "Maximum number of items to fetch")
pr_listCmd.Flags().Bool("no-web", false, "Open overview of issues in the web browser")
pr_listCmd.Flags().StringP("state", "s", "", "Filter by state")
pr_listCmd.Flags().BoolP("web", "w", false, "Open overview of issues in the web browser")
prCmd.AddCommand(pr_listCmd)
// TODO flag completion
carapace.Gen(pr_listCmd).FlagCompletion(carapace.ActionMap{
"assignee": carapace.ActionValues(),
"label": carapace.ActionValues(),
"limit": carapace.ActionValues(),
"state": carapace.ActionValues("open", "closed", "merged", "all"),
})
}

View File

@ -0,0 +1,19 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var pr_openCmd = &cobra.Command{
Use: "open [OPTIONS] [PULLREQUEST_ID]",
Short: "Alias: `doing open pr`",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(pr_openCmd).Standalone()
pr_openCmd.Flags().Bool("help", false, "Show this message and exit.")
prCmd.AddCommand(pr_openCmd)
}

View File

@ -0,0 +1,23 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "doing [OPTIONS] COMMAND [ARGS]...",
Short: "CLI for repository/issue workflow on Azure Devops",
Long: "https://github.com/ing-bank/doing-cli",
Run: func(cmd *cobra.Command, args []string) {},
}
func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()
rootCmd.Flags().Bool("help", false, "Show this message and exit.")
rootCmd.Flags().Bool("version", false, "Show the version and exit.")
}

View File

@ -0,0 +1,51 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/doing"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/git"
"github.com/spf13/cobra"
)
var workonCmd = &cobra.Command{
Use: "workon [OPTIONS] ISSUE",
Short: "Create issue with PR and switch git branch",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(workonCmd).Standalone()
workonCmd.Flags().Bool("add-to-current-sprint", false, "Add item to the current sprint")
workonCmd.Flags().Bool("auto-complete", false, "Set the PR to complete autom. when all policies have passed")
workonCmd.Flags().String("branch-prefix", "", "The prefix to be prepended to the branch name")
workonCmd.Flags().Bool("checkout", false, "Run git commands to checkout remote branch locally")
workonCmd.Flags().StringP("default-branch", "b", "", "The name of the branch to branch from and to")
workonCmd.Flags().Bool("delete-source-branch", false, "Set to delete source branch when pull request completes")
workonCmd.Flags().Bool("do-not-add-to-current-sprint", false, "Do not add item to the current sprint")
workonCmd.Flags().Bool("draft", false, "Create draft/WIP pull request")
workonCmd.Flags().Bool("help", false, "Show this message and exit")
workonCmd.Flags().StringP("label", "l", "", "Attach tags (labels) to work item")
workonCmd.Flags().Bool("no-auto-complete", false, "Do not set the PR to complete autom. when all policies have passed")
workonCmd.Flags().Bool("no-checkout", false, "Do not run git commands to checkout remote branch locally")
workonCmd.Flags().Bool("no-delete-source-branch", false, "Set to delete source branch when pull request completes")
workonCmd.Flags().Bool("no-draft", false, "Do not create draft/WIP pull request")
workonCmd.Flags().Bool("no-self-approve", false, "Do not add yourself as reviewer and add your approval")
workonCmd.Flags().StringP("parent", "p", "", "To create a child work item, specify the ID of the parent work item")
workonCmd.Flags().StringP("reviewers", "r", "", "Space separated list of reviewer emails")
workonCmd.Flags().Bool("self-approve", false, "Add yourself as reviewer and add your approval")
workonCmd.Flags().StringP("story-points", "s", "", "The number of story points to assign")
workonCmd.Flags().String("type", "", "Type of work item")
rootCmd.AddCommand(workonCmd)
carapace.Gen(workonCmd).FlagCompletion(carapace.ActionMap{
"default-branch": git.ActionRefs(git.RefOption{LocalBranches: true, RemoteBranches: true}), // TODO test
"label": carapace.ActionValues(), // TODO
"parent": carapace.ActionValues(), // TODO
"reviewers": carapace.ActionValues(), // TODO
"story-points": carapace.ActionValues(), // TODO
"type": doing.ActionWorkItemTypes(),
})
// TODO positional completion
}

View File

@ -0,0 +1,7 @@
package main
import "github.com/carapace-sh/carapace-bin/completers/doing_completer/cmd"
func main() {
cmd.Execute()
}

View File

@ -0,0 +1,16 @@
package doing
import "github.com/carapace-sh/carapace"
// ActionWorkItemTypes completes work item types
func ActionWorkItemTypes() carapace.Action {
return carapace.ActionValues(
"Bug",
"Epic",
"Feature",
"Issue",
"Task",
"Test Case",
"User Story",
)
}