-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from vladimirvivien/repackage
Complete refactor of codebase and additional functionalities.
- Loading branch information
Showing
48 changed files
with
2,350 additions
and
1,590 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
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,4 +1,4 @@ | ||
package echo | ||
package gexe | ||
|
||
// Config stores configuration | ||
type Config struct { | ||
|
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,45 +1,32 @@ | ||
package echo | ||
package gexe | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
|
||
"github.com/vladimirvivien/gexe/prog" | ||
"github.com/vladimirvivien/gexe/vars" | ||
) | ||
|
||
var ( | ||
DefaultEcho = New() | ||
spaceRgx = regexp.MustCompile("\\s") | ||
lineRgx = regexp.MustCompile("\\n") | ||
) | ||
|
||
// Echo represents a new Echo session | ||
type Echo struct { | ||
vars map[string]string // session var | ||
Conf *Config // session config | ||
Procs []Proc // executed processes | ||
Prog *prog // progam info | ||
err error | ||
vars *vars.Variables // session vars | ||
prog *prog.ProgInfo | ||
Conf *Config // session config | ||
} | ||
|
||
var ( | ||
spaceRgx = regexp.MustCompile("\\s") | ||
lineRgx = regexp.MustCompile("\\n") | ||
) | ||
|
||
// New creates a new Echo session | ||
func New() *Echo { | ||
e := &Echo{ | ||
vars: make(map[string]string), | ||
vars: vars.New(), | ||
prog: prog.Prog(), | ||
Conf: &Config{escapeChar: '\\'}, | ||
Prog: new(prog), | ||
} | ||
return e | ||
} | ||
|
||
func (e *Echo) shouldPanic(msg string) { | ||
if e.Conf.IsPanicOnErr() { | ||
panic(msg) | ||
} | ||
} | ||
|
||
func (e *Echo) shouldLog(msg string) { | ||
if e.Conf.IsVerbose() { | ||
fmt.Println(msg) | ||
} | ||
} | ||
|
||
func (e *Echo) String() string { | ||
return fmt.Sprintf("Vars[%#v]", e.vars) | ||
} |
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 +1,5 @@ | ||
# `echo` Examples | ||
* [build](./build/main.go) - Show how to build Go binaries for multiple platforms and OSes. | ||
* [git](./git/main.go) - Uses git to print logs and commit info | ||
* [helloecho](./helloecho/main.go) - Simple example Echo | ||
* [ping](./ping/main.go) - Stream output of long-running processes |
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
Oops, something went wrong.