mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 22:27:13 +09:00
Support filetype option as command line option
This commit is contained in:
@@ -52,8 +52,9 @@ func InitFlags() {
|
||||
optionFlags = make(map[string]*string)
|
||||
|
||||
for k, v := range config.DefaultGlobalSettings() {
|
||||
optionFlags[k] = flag.String(k, "", fmt.Sprintf("The %s option. Default value: '%v'", k, v))
|
||||
optionFlags[k] = flag.String(k, "", fmt.Sprintf("The %s option. Default value: '%v'.", k, v))
|
||||
}
|
||||
optionFlags["filetype"] = flag.String("filetype", "", fmt.Sprintf("The filetype option. Autodetected by default."))
|
||||
|
||||
flag.Parse()
|
||||
|
||||
@@ -153,13 +154,15 @@ func main() {
|
||||
|
||||
// flag options
|
||||
for k, v := range optionFlags {
|
||||
if *v != "" {
|
||||
if *v != "" && k != "filetype" {
|
||||
nativeValue, err := config.GetNativeValue(k, config.GlobalSettings[k], *v)
|
||||
if err != nil {
|
||||
screen.TermMessage(err)
|
||||
continue
|
||||
}
|
||||
config.GlobalSettings[k] = nativeValue
|
||||
} else if k == "filetype" && *v != "" {
|
||||
config.GlobalSettings[k] = *v
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +199,10 @@ func main() {
|
||||
action.InitTabs(b)
|
||||
action.InitGlobals()
|
||||
|
||||
if _, ok := config.GlobalSettings["filetype"]; ok {
|
||||
delete(config.GlobalSettings, "filetype")
|
||||
}
|
||||
|
||||
// Here is the event loop which runs in a separate thread
|
||||
go func() {
|
||||
events = make(chan tcell.Event)
|
||||
|
||||
Reference in New Issue
Block a user