From d358607c3816709b744e89ff50f1207f229b2fcc Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 7 Mar 2024 21:09:20 +0900 Subject: [PATCH] Fix some arguments handlings I with this is not the cause of #442 --- cmd/winit-conf/main.go | 9 ++++----- cmd/winit-reg/main.go | 7 +++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/winit-conf/main.go b/cmd/winit-conf/main.go index 1b0f040d..6581136a 100644 --- a/cmd/winit-conf/main.go +++ b/cmd/winit-conf/main.go @@ -106,14 +106,13 @@ func (p provisioner) Copy() error { func main() { pwshProfilePathFlag := flag.String("pwsh_profile_path", "", "Specify PowerShell profile path") flag.Parse() - // $PROFILE is an "Automatic Variables", not ENV - // https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.4 - pwshProfilePath := filepath.Clean(*pwshProfilePathFlag) - - if pwshProfilePath == "" { + if *pwshProfilePathFlag == "" { flag.Usage() log.Fatalf("called with wrong arguments") } + // $PROFILE is an "Automatic Variables", not ENV + // https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.4 + pwshProfilePath := filepath.Clean(*pwshProfilePathFlag) for _, p := range provisioners(pwshProfilePath) { log.Printf("%s => %s\n", p.EmbedPath(), p.DstPath()) diff --git a/cmd/winit-reg/main.go b/cmd/winit-reg/main.go index f7077dca..0f19c15e 100644 --- a/cmd/winit-reg/main.go +++ b/cmd/winit-reg/main.go @@ -41,6 +41,13 @@ func main() { runCmd := flag.NewFlagSet("run", flag.ExitOnError) actionFlag := runCmd.String("action", "", "which action you want to do") allFlag := runCmd.Bool("all", false, "do ALL if you trust me") + flag.Parse() + + if len(os.Args) < 1 { + flag.Usage() + + os.Exit(1) + } switch os.Args[1] { case "list":