cmd

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:          "gnb",
	Short:        "ganbatte - for lazy developers | 頑張って !",
	Long:         `워크플로우/단축어 관리 CLI. lazyasf의 정신적 후속작으로, 단순 alias 관리를 넘어 명령 시퀀스를 워크플로우로 묶고, shell history에서 패턴을 자동 발굴해 추천하는 도구.`,
	SilenceUsage: true,
	RunE: func(cmd *cobra.Command, args []string) error {
		scoped, err := config.LoadScoped()
		if err != nil {
			return fmt.Errorf("loading config: %w", err)
		}
		cfg := scoped.Merged

		items := tui.ItemsFromScopedConfig(scoped)
		if len(items) == 0 {
			cmd.Println("No aliases or workflows configured.")
			cmd.Println("Run 'gnb init' to get started, then 'gnb add <name> <command>' to add aliases.")
			return nil
		}

		if !isInteractiveTerminal(os.Stdin) {
			return fmt.Errorf("TUI requires an interactive terminal; use 'gnb list' or 'gnb run <name>' in scripts")
		}

		m := tui.New(items)
		p := tea.NewProgram(m, tea.WithAltScreen())
		finalModel, err := p.Run()
		if err != nil {
			return fmt.Errorf("running TUI: %w", err)
		}

		result := finalModel.(tui.Model)
		if result.SelectedItem == nil {
			return nil
		}

		item := result.SelectedItem

		switch result.SelectedAction {
		case tui.ActionRun:
			return handleRun(scoped, item)
		case tui.ActionEdit:
			return handleEdit(cfg, item)
		case tui.ActionDelete:
			return handleDelete(cfg, item)
		}

		return nil
	},
}

RootCmd represents the base command when called without any subcommands

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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