-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- FIXME: cant get the std error when git command is not executed correctly
- Loading branch information
Showing
4 changed files
with
64 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,29 @@ | ||
package app | ||
|
||
import ( | ||
// "github.com/dyweb/Ayi/app/git" | ||
) | ||
"github.com/codegangsta/cli" | ||
"github.com/dyweb/Ayi/app/git" | ||
"log" | ||
) | ||
|
||
// GitCommands wrap common git operations with config defined in Ayi | ||
var GitCommands = cli.Command{ | ||
Name: "git", | ||
Aliases: []string{"g"}, | ||
Usage: "git command wrapper", | ||
Subcommands: []cli.Command{ | ||
{ | ||
Name: "status", | ||
Aliases: []string{"s"}, | ||
Usage: "git status", | ||
Action: func(c *cli.Context) { | ||
out, err, e := git.Status{}.Execute() | ||
if e != nil { | ||
println(err) | ||
log.Fatal(e) | ||
} | ||
println(out) | ||
}, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
package git | ||
|
||
// wrap git command for clone | ||
import ( | ||
"os/exec" | ||
) | ||
|
||
var cmdName = "git" | ||
|
||
// simpleCommand is a interface execute and return output as string | ||
type simpleCommand interface { | ||
Execute() (stdOut string, stdErr string, err error) | ||
} | ||
|
||
// Status execute git status command and return output | ||
type Status struct { | ||
} | ||
|
||
// Execute execute git status and return output as string | ||
func (s Status) Execute() (stdOut string, stdErr string, err error) { | ||
var cmdOut []byte | ||
err = nil | ||
cmdArgs := []string{"status"} | ||
cmdOut, err = exec.Command(cmdName, cmdArgs...).Output() | ||
// FIXME: cant get correct error output | ||
if err != nil{ | ||
stdErr = err.Error() | ||
} | ||
// TODO: get return code? | ||
return string(cmdOut), stdErr, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters