Update shell funcs

This commit is contained in:
Ryan McGuire 2023-12-09 23:45:30 -05:00
parent 64e07d3f40
commit 78662b3e09
8 changed files with 39 additions and 10 deletions

View File

@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
)
@ -16,7 +17,14 @@ var aliasListCmd = &cobra.Command{
}
func runListAliasCmd(cmd *cobra.Command, args []string) {
fmt.Print("\n" + cache.AliasesByProjectString() + "\n")
fmt.Println()
pterm.DefaultBox.
WithLeftPadding(5).WithRightPadding(5).
WithBoxStyle(&pterm.Style{pterm.FgLightBlue}).
WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Aliases by Project"))).
Print("\n" + cache.AliasesByProjectString())
fmt.Println("\n")
// fmt.Print("\n" + cache.AliasesByProjectString() + "\n")
}
func init() {

View File

@ -12,7 +12,6 @@ var projectCmd = &cobra.Command{
Aliases: []string{"proj", "projects", "p"},
Args: cobra.MaximumNArgs(1),
ArgAliases: []string{"alias"},
ValidArgsFunction: validAliasesFunc,
Long: projCmdLong,
PersistentPreRun: initProjectCmd,
PersistentPostRun: postProjectCmd,

View File

@ -26,6 +26,11 @@ func projectGoCmdRun(cmd *cobra.Command, args []string) {
}
// project := getProject(args)
project := fzfSearchProjectAliases(term)
if project == nil {
plog.Fatal("No project selected, nowhere to go")
}
cache.GoTo(project)
project.SetRepo(cache.OpenProject(cmd.Context(), project))

View File

@ -10,7 +10,7 @@ import (
var projectListCmd = &cobra.Command{
Use: "list",
Short: "List GitLab Projects",
Aliases: []string{"ls", "show"},
Aliases: []string{"ls"},
Long: projListCmdLong,
Run: projectListCmdRun,
}

View File

@ -10,7 +10,6 @@ var projectShowCmd = &cobra.Command{
Use: "show [fuzzy alias search]",
Short: "Show detail for a GitLab project",
Args: cobra.ArbitraryArgs,
ValidArgsFunction: validProjectsOrAliasesFunc,
Long: projShowCmdLong,
Run: projectShowCmdRun,
}

View File

@ -17,6 +17,7 @@ var plog *pterm.Logger
var rootCmd = &cobra.Command{
Use: "gitlab-project-manager",
Aliases: []string{"gpm"},
Short: "Find and use GitLab projects locally",
Long: rootCmdLong,
PersistentPreRun: initRootCmd,

17
contrib/gpm_funcs.sh Normal file
View File

@ -0,0 +1,17 @@
# Go to a project, specify a fzf filter or filter
# through them all
pgo () {
project=` gitlab-project-manager project cd $1 `
if [ $? -eq 0 ]; then
cd $project
fi
}
# Add a new project to your local projects path
padd () {
gitlab-project-manager project add
}
plist () {
gitlab-project-manager alias list
}

View File

@ -23,7 +23,7 @@ func (c *Cache) FuzzyFindAlias(name string) []*ProjectAlias {
for i, r := range ranks {
found[i] = r.Target
}
c.log.Warn("Fuzzy found multiple aliases, try being more specific",
c.log.Debug("Fuzzy found multiple aliases, try being more specific",
c.log.Args("foundAliases", strings.Join(found, ", ")))
}
var aliases []*ProjectAlias