package main import ( "flag" "fmt" "io" "log" "os" "os/signal" "path/filepath" "regexp" "runtime" "runtime/pprof" "sort" "strconv" "syscall" "time" "github.com/go-errors/errors" isatty "github.com/mattn/go-isatty" "github.com/micro-editor/micro/v2/internal/action" "github.com/micro-editor/micro/v2/internal/buffer" "github.com/micro-editor/micro/v2/internal/clipboard" "github.com/micro-editor/micro/v2/internal/config" "github.com/micro-editor/micro/v2/internal/screen" "github.com/micro-editor/micro/v2/internal/shell" "github.com/micro-editor/micro/v2/internal/util" "github.com/micro-editor/tcell/v2" lua "github.com/yuin/gopher-lua" ) var ( // Command line flags flagVersion = flag.Bool("version", false, "Show the version number and information") flagConfigDir = flag.String("config-dir", "", "Specify a custom location for the configuration directory") flagOptions = flag.Bool("options", false, "Show all option help") flagDebug = flag.Bool("debug", false, "Enable debug mode (prints debug info to ./log.txt)") flagProfile = flag.Bool("profile", false, "Enable CPU profiling (writes profile info to ./micro.prof)") flagPlugin = flag.String("plugin", "", "Plugin command") flagClean = flag.Bool("clean", false, "Clean configuration directory") optionFlags map[string]*string sighup chan os.Signal timerChan chan func() ) func InitFlags() { // Note: keep this in sync with the man page in assets/packaging/micro.1 flag.Usage = func() { fmt.Println("Usage: micro [OPTION]... [FILE]... [+LINE[:COL]] [+/REGEX]") fmt.Println(" micro [OPTION]... [FILE[:LINE[:COL]]]... (only if the `parsecursor` option is enabled)") fmt.Println("-clean") fmt.Println(" \tClean the configuration directory and exit") fmt.Println("-config-dir dir") fmt.Println(" \tSpecify a custom location for the configuration directory") fmt.Println("FILE:LINE[:COL] (only if the `parsecursor` option is enabled)") fmt.Println("FILE +LINE[:COL]") fmt.Println(" \tSpecify a line and column to start the cursor at when opening a buffer") fmt.Println("+/REGEX") fmt.Println(" \tSpecify a regex to search for when opening a buffer") fmt.Println("-options") fmt.Println(" \tShow all options help and exit") fmt.Println("-debug") fmt.Println(" \tEnable debug mode (enables logging to ./log.txt)") fmt.Println("-profile") fmt.Println(" \tEnable CPU profiling (writes profile info to ./micro.prof") fmt.Println(" \tso it can be analyzed later with \"go tool pprof micro.prof\")") fmt.Println("-version") fmt.Println(" \tShow the version number and information and exit") fmt.Print("\nMicro's plugins can be managed at the command line with the following commands.\n") fmt.Println("-plugin install [PLUGIN]...") fmt.Println(" \tInstall plugin(s)") fmt.Println("-plugin remove [PLUGIN]...") fmt.Println(" \tRemove plugin(s)") fmt.Println("-plugin update [PLUGIN]...") fmt.Println(" \tUpdate plugin(s) (if no argument is given, updates all plugins)") fmt.Println("-plugin search [PLUGIN]...") fmt.Println(" \tSearch for a plugin") fmt.Println("-plugin list") fmt.Println(" \tList installed plugins") fmt.Println("-plugin available") fmt.Println(" \tList available plugins") fmt.Print("\nMicro's options can also be set via command line arguments for quick\nadjustments. For real configuration, please use the settings.json\nfile (see 'help options').\n\n") fmt.Println("-