Repository: danielmiessler/fabric
File: cli/flags.go (Go)

Code before:
	ModelContextLength              int               `long:"modelContextLength" yaml:"modelContextLength" description:"Model context length (only affects ollama)"`
	Output                          string            `short:"o" long:"output" description:"Output to file" default:""`
	OutputSession                   bool              `long:"output-session" description:"Output the entire session (also a temporary one) to the output file"`
	LatestPatterns                  string            `short:"n" long:"latest" description:"Number of latest patterns to list" default:"0"`
	ChangeDefaultModel              bool              `short:"d" long:"changeDefaultModel" description:"Change default model"`
	YouTube                         string            `short:"y" long:"youtube" description:"YouTube video or play list \"URL\" to grab transcript, comments from it and send to chat or print it put to the console and store it in the output file"`
	YouTubePlaylist                 bool              `long:"playlist" description:"Prefer playlist over video if both ids are present in the URL"`
	YouTubeTranscript               bool              `long:"transcript" description:"Grab transcript from YouTube video and send to chat (it is used per default)."`
	YouTubeTranscriptWithTimestamps bool              `long:"transcript-with-timestamps" description:"Grab transcript from YouTube video with timestamps and send to chat"`
	YouTubeComments                 bool              `long:"comments" description:"Grab comments from YouTube video and send to chat"`
	YouTubeMetadata                 bool              `long:"metadata" description:"Output video metadata"`
	Language                        string            `short:"g" long:"language" description:"Specify the Language Code for the chat, e.g. -g=en -g=zh" default:""`
	ScrapeURL                       string            `short:"u" long:"scrape_url" description:"Scrape website URL to markdown using Jina AI"`
	ScrapeQuestion                  string            `short:"q" long:"scrape_question" description:"Search question using Jina AI"`
	Seed                            int               `short:"e" long:"seed" yaml:"seed" description:"Seed to be used for LMM generation"`
	WipeContext                     string            `short:"w" long:"wipecontext" description:"Wipe context"`
	WipeSession                     string            `short:"W" long:"wipesession" description:"Wipe session"`
	PrintContext                    string            `long:"printcontext" description:"Print context"`
	PrintSession                    string            `long:"printsession" description:"Print session"`
	HtmlReadability                 bool              `long:"readability" description:"Convert HTML input into a clean, readable view"`
	InputHasVars                    bool              `long:"input-has-vars" description:"Apply variables to user input"`
	DryRun                          bool              `long:"dry-run" description:"Show what would be sent to the model without actually sending it"`
	Serve                           bool              `long:"serve" description:"Serve the Fabric Rest API"`
	ServeOllama                     bool              `long:"serveOllama" description:"Serve the Fabric Rest API with ollama endpoints"`
	ServeAddress                    string            `long:"address" description:"The address to bind the REST API" default:":8080"`
	ServeApiKey                     string            `long:"apikey" description:"API key used to secure server routes" default:""`
	Config                          string            `long:"config" description:"Path to YAML config file"`
	Version                         bool              `long:"version" description:"Print current version"`
	ListExtensions                  bool              `long:"listextensions" description:"List all registered extensions"`
	AddExtension                    string            `long:"addextension" description:"Register a new extension from config file path"`
	RemoveExtension                 string            `long:"rmextension" description:"Remove a registered extension by name"`
	Strategy                        string            `long:"strategy" description:"Choose a strategy from the available strategies" default:""`
	ListStrategies                  bool              `long:"liststrategies" description:"List all strategies"`
}

var debug = false

func Debugf(format string, a ...interface{}) {
	if debug {
		fmt.Printf("DEBUG: "+format, a...)
	}
}

// Init Initialize flags. returns a Flags struct and an error
func Init() (ret *Flags, err error) {
	// Track which yaml-configured flags were set on CLI
	usedFlags := make(map[string]bool)
	yamlArgsScan := os.Args[1:]

	// Get list of fields that have yaml tags, could be in yaml config
	yamlFields := make(map[string]bool)

Review comment (suggestion):
I suggest changing this to:

```go
ServeAPIKey string `long:"api-key" description:"API key used to secure server routes" default:""`
```

- Use `ServeAPIKey` rather than `ServeApiKey` to match the standard Go naming convention for acronyms (e.g., "API", "HTTP").
- Using a hyphen (`api-key`) in CLI arguments is a common convention that improves readability and consistency across CLI tools.

Code after:
	ModelContextLength              int               `long:"modelContextLength" yaml:"modelContextLength" description:"Model context length (only affects ollama)"`
	Output                          string            `short:"o" long:"output" description:"Output to file" default:""`
	OutputSession                   bool              `long:"output-session" description:"Output the entire session (also a temporary one) to the output file"`
	LatestPatterns                  string            `short:"n" long:"latest" description:"Number of latest patterns to list" default:"0"`
	ChangeDefaultModel              bool              `short:"d" long:"changeDefaultModel" description:"Change default model"`
	YouTube                         string            `short:"y" long:"youtube" description:"YouTube video or play list \"URL\" to grab transcript, comments from it and send to chat or print it put to the console and store it in the output file"`
	YouTubePlaylist                 bool              `long:"playlist" description:"Prefer playlist over video if both ids are present in the URL"`
	YouTubeTranscript               bool              `long:"transcript" description:"Grab transcript from YouTube video and send to chat (it is used per default)."`
	YouTubeTranscriptWithTimestamps bool              `long:"transcript-with-timestamps" description:"Grab transcript from YouTube video with timestamps and send to chat"`
	YouTubeComments                 bool              `long:"comments" description:"Grab comments from YouTube video and send to chat"`
	YouTubeMetadata                 bool              `long:"metadata" description:"Output video metadata"`
	Language                        string            `short:"g" long:"language" description:"Specify the Language Code for the chat, e.g. -g=en -g=zh" default:""`
	ScrapeURL                       string            `short:"u" long:"scrape_url" description:"Scrape website URL to markdown using Jina AI"`
	ScrapeQuestion                  string            `short:"q" long:"scrape_question" description:"Search question using Jina AI"`
	Seed                            int               `short:"e" long:"seed" yaml:"seed" description:"Seed to be used for LMM generation"`
	WipeContext                     string            `short:"w" long:"wipecontext" description:"Wipe context"`
	WipeSession                     string            `short:"W" long:"wipesession" description:"Wipe session"`
	PrintContext                    string            `long:"printcontext" description:"Print context"`
	PrintSession                    string            `long:"printsession" description:"Print session"`
	HtmlReadability                 bool              `long:"readability" description:"Convert HTML input into a clean, readable view"`
	InputHasVars                    bool              `long:"input-has-vars" description:"Apply variables to user input"`
	DryRun                          bool              `long:"dry-run" description:"Show what would be sent to the model without actually sending it"`
	Serve                           bool              `long:"serve" description:"Serve the Fabric Rest API"`
	ServeOllama                     bool              `long:"serveOllama" description:"Serve the Fabric Rest API with ollama endpoints"`
	ServeAddress                    string            `long:"address" description:"The address to bind the REST API" default:":8080"`
	ServeAPIKey                     string            `long:"api-key" description:"API key used to secure server routes" default:""`
	Config                          string            `long:"config" description:"Path to YAML config file"`
	Version                         bool              `long:"version" description:"Print current version"`
	ListExtensions                  bool              `long:"listextensions" description:"List all registered extensions"`
	AddExtension                    string            `long:"addextension" description:"Register a new extension from config file path"`
	RemoveExtension                 string            `long:"rmextension" description:"Remove a registered extension by name"`
	Strategy                        string            `long:"strategy" description:"Choose a strategy from the available strategies" default:""`
	ListStrategies                  bool              `long:"liststrategies" description:"List all strategies"`
}

var debug = false

func Debugf(format string, a ...interface{}) {
	if debug {
		fmt.Printf("DEBUG: "+format, a...)
	}
}

// Init Initialize flags. returns a Flags struct and an error
func Init() (ret *Flags, err error) {
	// Track which yaml-configured flags were set on CLI
	usedFlags := make(map[string]bool)
	yamlArgsScan := os.Args[1:]

	// Get list of fields that have yaml tags, could be in yaml config
	yamlFields := make(map[string]bool)