cmd

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package cmd defines the CLI commands for PuzzleTea using Cobra.

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:     "puzzletea",
	Version: Version,
	Short:   "A terminal-based puzzle game framework",
	Long:    "PuzzleTea is a terminal-based puzzle game framework featuring Nonogram, Nurikabe, Sudoku, Word Search, Hashiwokakero, and Lights Out.",
	RunE: func(cmd *cobra.Command, args []string) error {
		cfg := loadActiveConfig()

		if flagSetSeed != "" {
			if flagNew != "" || flagContinue != "" {
				return fmt.Errorf("--set-seed cannot be combined with --new or --continue")
			}
			return launchSeededGameFn(flagSetSeed, cfg)
		}
		if flagNew != "" {
			parts := strings.SplitN(flagNew, ":", 2)
			gameArg := parts[0]
			var modeArg string
			if len(parts) > 1 {
				modeArg = parts[1]
			}
			return launchNewGameFn(gameArg, modeArg, "", cfg)
		}
		if flagContinue != "" {
			return continueGameFn(flagContinue, cfg)
		}

		s, err := openStoreFn(cfg.DBPath)
		if err != nil {
			return err
		}
		defer s.Close()
		p := tea.NewProgram(app.InitialModel(s, cfg))
		_, err = p.Run()
		return err
	},
}

RootCmd is the top-level Cobra command.

View Source
var Version = "dev"

Version is set at build time via ldflags:

go build -ldflags "-X github.com/FelineStateMachine/puzzletea/cmd.Version=v1.0.0"

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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