-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
130 additions
and
45 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
build: | ||
go build -race -v -o couper main.go | ||
|
||
image: | ||
docker build -t avenga/couper:latest . | ||
|
||
|
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,18 +1,55 @@ | ||
package command | ||
|
||
// Help shows available commands and options. | ||
func Help() { // TODO: generate from command and options list | ||
println(`couper usage: | ||
import ( | ||
"context" | ||
"fmt" | ||
|
||
couper <cmd> <options> | ||
"github.com/avenga/couper/config" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
global options: | ||
var _ Cmd = &Help{} | ||
|
||
-f couper hcl configuration file | ||
-log-format format option for json or common logs | ||
// Synopsis shows available commands and options. | ||
func Synopsis() { // TODO: generate from command and options list | ||
println(` | ||
Couper usage: | ||
couper <cmd> <options> | ||
available commands: | ||
Available commands: | ||
run Start the server with given configuration file. | ||
version Print the current version and build information. | ||
help Usage for given command. | ||
run starts the server | ||
Examples: | ||
couper run | ||
couper run -f couper.hcl | ||
couper run -watch -log-format json -log-pretty -p 3000 | ||
`) | ||
} | ||
|
||
type Help struct { | ||
ctx context.Context | ||
} | ||
|
||
func NewHelp(ctx context.Context) *Help { | ||
return &Help{ctx: ctx} | ||
} | ||
|
||
func (h Help) Execute(args Args, _ *config.Couper, _ *logrus.Entry) error { | ||
defer Synopsis() | ||
if len(args) == 0 { | ||
h.Usage() | ||
return fmt.Errorf("missing command argument") | ||
} | ||
cmd := NewCommand(h.ctx, args[0]) | ||
if cmd == nil { | ||
return fmt.Errorf("unknown command: %s", args[0]) | ||
} | ||
cmd.Usage() | ||
return nil | ||
} | ||
|
||
func (h Help) Usage() { | ||
println("Usage of help:\n help <command> Print usage information of given command.") | ||
} |
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