Update shell funcs
This commit is contained in:
parent
64e07d3f40
commit
78662b3e09
@ -3,6 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/pterm/pterm"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,7 +17,14 @@ var aliasListCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runListAliasCmd(cmd *cobra.Command, args []string) {
|
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() {
|
func init() {
|
||||||
|
@ -12,7 +12,6 @@ var projectCmd = &cobra.Command{
|
|||||||
Aliases: []string{"proj", "projects", "p"},
|
Aliases: []string{"proj", "projects", "p"},
|
||||||
Args: cobra.MaximumNArgs(1),
|
Args: cobra.MaximumNArgs(1),
|
||||||
ArgAliases: []string{"alias"},
|
ArgAliases: []string{"alias"},
|
||||||
ValidArgsFunction: validAliasesFunc,
|
|
||||||
Long: projCmdLong,
|
Long: projCmdLong,
|
||||||
PersistentPreRun: initProjectCmd,
|
PersistentPreRun: initProjectCmd,
|
||||||
PersistentPostRun: postProjectCmd,
|
PersistentPostRun: postProjectCmd,
|
||||||
|
@ -26,6 +26,11 @@ func projectGoCmdRun(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
// project := getProject(args)
|
// project := getProject(args)
|
||||||
project := fzfSearchProjectAliases(term)
|
project := fzfSearchProjectAliases(term)
|
||||||
|
|
||||||
|
if project == nil {
|
||||||
|
plog.Fatal("No project selected, nowhere to go")
|
||||||
|
}
|
||||||
|
|
||||||
cache.GoTo(project)
|
cache.GoTo(project)
|
||||||
project.SetRepo(cache.OpenProject(cmd.Context(), project))
|
project.SetRepo(cache.OpenProject(cmd.Context(), project))
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
var projectListCmd = &cobra.Command{
|
var projectListCmd = &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
Short: "List GitLab Projects",
|
Short: "List GitLab Projects",
|
||||||
Aliases: []string{"ls", "show"},
|
Aliases: []string{"ls"},
|
||||||
Long: projListCmdLong,
|
Long: projListCmdLong,
|
||||||
Run: projectListCmdRun,
|
Run: projectListCmdRun,
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var projectShowCmd = &cobra.Command{
|
var projectShowCmd = &cobra.Command{
|
||||||
Use: "show [fuzzy alias search]",
|
Use: "show [fuzzy alias search]",
|
||||||
Short: "Show detail for a GitLab project",
|
Short: "Show detail for a GitLab project",
|
||||||
Args: cobra.ArbitraryArgs,
|
Args: cobra.ArbitraryArgs,
|
||||||
ValidArgsFunction: validProjectsOrAliasesFunc,
|
Long: projShowCmdLong,
|
||||||
Long: projShowCmdLong,
|
Run: projectShowCmdRun,
|
||||||
Run: projectShowCmdRun,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func projectShowCmdRun(cmd *cobra.Command, args []string) {
|
func projectShowCmdRun(cmd *cobra.Command, args []string) {
|
||||||
|
@ -17,6 +17,7 @@ var plog *pterm.Logger
|
|||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "gitlab-project-manager",
|
Use: "gitlab-project-manager",
|
||||||
|
Aliases: []string{"gpm"},
|
||||||
Short: "Find and use GitLab projects locally",
|
Short: "Find and use GitLab projects locally",
|
||||||
Long: rootCmdLong,
|
Long: rootCmdLong,
|
||||||
PersistentPreRun: initRootCmd,
|
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 {
|
for i, r := range ranks {
|
||||||
found[i] = r.Target
|
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, ", ")))
|
c.log.Args("foundAliases", strings.Join(found, ", ")))
|
||||||
}
|
}
|
||||||
var aliases []*ProjectAlias
|
var aliases []*ProjectAlias
|
||||||
|
Loading…
Reference in New Issue
Block a user