commands

package
v0.3.25 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 23 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 cmd_addRepository(repoURL)
	},
}
View Source
var AskCmd = &cobra.Command{
	Use:   "ask <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 cmd_askQuestion(question)
	},
}
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 cmd_info()
	},
}
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 cmd_createPR(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 cmd_pullRepos(cmd)
	}),
}
View Source
var RunCmd = &cobra.Command{
	Use:   "run [scriptName]",
	Short: "Run scripts across all projects in your configuration.",
	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]
		}

		topics, _ := cmd.Flags().GetStringSlice("topics")
		count, _ := cmd.Flags().GetBool("count")
		outputFormats, _ := cmd.Flags().GetStringSlice("output")
		return cmd_runScript(scriptName, topics, count, outputFormats)
	}),
}
View Source
var SyncCmd = &cobra.Command{
	Use:   "sync",
	Short: "Sync project metadata from all configured code repositories.",
	RunE: func(cmd *cobra.Command, args []string) error {
		return cmd_syncRepos()
	},
}

SyncCmd is a Cobra command that synchronizes project metadata from a specified code repository. Currently, it supports syncing from GitHub. The command requires a single argument specifying the repository type (e.g., "github"). It uses the GITHUB_TOKEN environment variable for authentication.

Functions

func ExtractTypeScriptCode

func ExtractTypeScriptCode(response string) string

extractTypeScriptCode finds the first ```ts or ```typescript code block in a string and returns its contents.

func RunCmdInit

func RunCmdInit(cmd *cobra.Command)

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"`
	Skip     bool        `json:"skip,omitempty"`
	Metadata interface{} `json:"metadata,omitempty"`
}

Project and ProjectsJSON store information about cloned repos

type ProjectsJSON

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

type ScriptInfo

type ScriptInfo struct {
	Path    string   `json:"path"`
	Version string   `json:"version"`
	Output  string   `json:"output"`
	Columns []string `json:"columns"`
}

Jump to

Keyboard shortcuts

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