Update shell funcs
This commit is contained in:
parent
64e07d3f40
commit
78662b3e09
@ -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() {
|
||||
|
@ -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,
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -7,12 +7,11 @@ import (
|
||||
)
|
||||
|
||||
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,
|
||||
Use: "show [fuzzy alias search]",
|
||||
Short: "Show detail for a GitLab project",
|
||||
Args: cobra.ArbitraryArgs,
|
||||
Long: projShowCmdLong,
|
||||
Run: projectShowCmdRun,
|
||||
}
|
||||
|
||||
func projectShowCmdRun(cmd *cobra.Command, args []string) {
|
||||
|
@ -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
17
contrib/gpm_funcs.sh
Normal 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
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user