-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
55 changed files
with
5,521 additions
and
412 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DATABASE=db.example.com | ||
NULL= | ||
MODE=debug |
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,6 +1,6 @@ | ||
language: go | ||
go: | ||
- 1.4 | ||
- 1.5 | ||
- tip | ||
sudo: false | ||
install: | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"syscall" | ||
|
||
"github.com/kreuzwerker/envplate" | ||
"github.com/spf13/cobra" | ||
"github.com/yawn/doubledash" | ||
) | ||
|
||
var ( | ||
build string | ||
version string | ||
) | ||
|
||
func main() { | ||
|
||
var ( // flags | ||
backup *bool | ||
dryRun *bool | ||
strict *bool | ||
verbose *bool | ||
) | ||
|
||
os.Args = doubledash.Args | ||
|
||
// commands | ||
root := &cobra.Command{ | ||
Use: "ep", | ||
Short: "envplate provides trivial templating for configuration files using environment keys", | ||
PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||
envplate.Logger.Verbose = *verbose | ||
}, | ||
} | ||
|
||
parse := &cobra.Command{ | ||
Use: "parse", | ||
Short: "Parse globs and exec after doubledash", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
var h = envplate.Handler{ | ||
Backup: *backup, | ||
DryRun: *dryRun, | ||
Strict: *strict, | ||
} | ||
|
||
if err := h.Apply(args); err != nil { | ||
os.Exit(1) | ||
} | ||
|
||
if h.DryRun { | ||
os.Exit(0) | ||
} | ||
|
||
if len(doubledash.Xtra) > 0 { | ||
|
||
if err := syscall.Exec(doubledash.Xtra[0], doubledash.Xtra, os.Environ()); err != nil { | ||
log.Fatalf("Cannot exec '%v': %v", doubledash.Xtra, err) | ||
} | ||
|
||
} | ||
|
||
}, | ||
} | ||
|
||
version := &cobra.Command{ | ||
Use: "version", | ||
Short: "Print the version information of ep", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Printf("Envplate %s (%s)\n", version, build) | ||
}, | ||
} | ||
|
||
root.AddCommand(parse) | ||
root.AddCommand(version) | ||
|
||
// flag parsing | ||
backup = parse.Flags().BoolP("backup", "b", false, "Create a backup file when using inline mode") | ||
dryRun = parse.Flags().BoolP("dry-run", "d", false, "Dry-run - output templates to stdout instead of inline replacement") | ||
strict = parse.Flags().BoolP("strict", "s", false, "Strict-mode - fail when falling back on defaults") | ||
verbose = parse.Flags().BoolP("verbose", "v", false, "Verbose logging") | ||
|
||
if err := root.Execute(); err != nil { | ||
log.Fatalf("Failed to start the application: %v", err) | ||
} | ||
|
||
} |
Oops, something went wrong.