github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/cmd/jujud/main_windows.go (about) 1 // Copyright 2012, 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package main 5 6 import ( 7 "fmt" 8 "os" 9 "path/filepath" 10 11 "launchpad.net/juju-core/cmd" 12 ) 13 14 15 // Main is not redundant with main(), because it provides an entry point 16 // for testing with arbitrary command line arguments. 17 func Main(args []string) { 18 var code int = 1 19 var err error 20 commandName := filepath.Base(args[0]) 21 if commandName == "jujud.exe" { 22 code, err = jujuDMain(args) 23 } else if commandName == "jujuc.exe" { 24 fmt.Fprint(os.Stderr, jujudDoc) 25 code = 2 26 err = fmt.Errorf("jujuc should not be called directly") 27 } else if commandName == "juju-run.exe" { 28 code = cmd.Main(&RunCommand{}, cmd.DefaultContext(), args[1:]) 29 } else { 30 code, err = jujuCMain(commandName, args) 31 } 32 if err != nil { 33 fmt.Fprintf(os.Stderr, "error: %v\n", err) 34 } 35 os.Exit(code) 36 }