commands

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddCmd = &cobra.Command{
	Use:   "add <repo-url>",
	Short: "Add a new repository and clone it locally.",
	Args:  cobra.ExactArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		repoURL := args[0]
		return addRepository(repoURL)
	},
}
View Source
var InfoCmd = &cobra.Command{
	Use:   "info",
	Short: "Displays information about projects and available scripts",
	RunE: func(cmd *cobra.Command, args []string) error {
		return displayInfo()
	},
}

InfoCmd represents the info command

View Source
var PRCmd = &cobra.Command{
	Use:   "pr <message>",
	Short: "Open a pull request for each repository (placeholder).",
	Args:  cobra.ArbitraryArgs,
	RunE: WrapWithMetrics(func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return errors.New("please provide a pull request message after 'pr'")
		}
		message := strings.Join(args, " ")
		return createPullRequest(message)
	}),
}
View Source
var PullCmd = &cobra.Command{
	Use:   "pull",
	Short: "Pull the latest changes for all repositories in projects.json",
	RunE: WrapWithMetrics(func(cmd *cobra.Command, args []string) error {
		return pullAllRepositories(cmd)
	}),
}
View Source
var QueryCmd = &cobra.Command{
	Use:   "query <question>",
	Short: "Generate a TypeScript script from an OpenAI query.",
	Args:  cobra.ArbitraryArgs,
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return errors.New("please provide a question after 'query'")
		}
		question := strings.Join(args, " ")
		return queryQuestion(question)
	},
}
View Source
var RunCmd = &cobra.Command{
	Use:   "run [scriptName]",
	Short: "Run a script (or all .ts scripts) across all projects",
	Args:  cobra.MaximumNArgs(1),
	RunE: WrapWithMetrics(func(cmd *cobra.Command, args []string) error {
		// Optional argument: the user can provide a script name or path
		var scriptName string
		if len(args) == 1 {
			scriptName = args[0]
		}
		return runScript(cmd, scriptName)
	}),
}

Functions

func WrapWithMetrics

func WrapWithMetrics(fn func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string) error

WrapWithMetrics wraps a command function to log its execution duration.

Types

type Project

type Project struct {
	Name    string   `json:"name"`
	Path    string   `json:"path"`
	RepoURL string   `json:"repoUrl"`
	Topics  []string `json:"topics"`
}

Project and ProjectsJSON store information about cloned repos

type ProjectsJSON

type ProjectsJSON struct {
	Projects []Project `json:"projects"`
}

Jump to

Keyboard shortcuts

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