Skip to content
Permalink
Browse files

change logs, metrics, and url commands to use `-s` flag for stage. Cl…

…oses #371 (BREAKING)
  • Loading branch information...
tj committed Apr 27, 2018
1 parent 49f950e commit e004cb497a2bdd30f2f1416fd1cf9a7718edcc5a
Showing with 34 additions and 41 deletions.
  1. +24 −31 docs/06-commands.md
  2. +3 −3 internal/cli/logs/logs.go
  3. +3 −3 internal/cli/metrics/metrics.go
  4. +4 −4 internal/cli/url/url.go
@@ -215,7 +215,7 @@ Flags:
--format="text" Output formatter.
--version Show application version.
-f, --follow Follow or tail the live logs.
-s, --since="1d" Show logs since duration (30s, 5m, 2h, 1h30m, 3d, 1M).
-S, --since="1d" Show logs since duration (30s, 5m, 2h, 1h30m, 3d, 1M).
-e, --expand Show expanded logs.
Args:
@@ -287,13 +287,13 @@ $ up logs
Show logs from the past 45 minutes.

```
$ up -s 45m logs
$ up -S 45m logs
```

Show logs from the past 12 hours.

```
$ up -s 12h logs
$ up -S 12h logs
```

Show live log output.
@@ -405,21 +405,18 @@ Show, open, or copy a stage endpoint.
```
Usage:
up url [<flags>] [<stage>]
up url [<flags>]
Flags:
-h, --help Output usage information.
-C, --chdir="." Change working directory.
-v, --verbose Enable verbose log output.
--format="text" Output formatter.
--version Show application version.
-o, --open Open endpoint in the browser.
-c, --copy Copy endpoint to the clipboard.
Args:
[<stage>] Name of the stage.
-h, --help Output usage information.
-C, --chdir="." Change working directory.
-v, --verbose Enable verbose log output.
--format="text" Output formatter.
--version Show application version.
-s, --stage="staging" Target stage name.
-o, --open Open endpoint in the browser.
-c, --copy Copy endpoint to the clipboard.
```

### Examples
@@ -445,19 +442,19 @@ $ up url --copy
Show the production endpoint.

```
$ up url production
$ up url -s production
```

Open the production endpoint in the browser.

```
$ up url -o production
$ up url -o -s production
```

Copy the production endpoint to the clipboard.

```
$ up url -c production
$ up url -c -s production
```

## Metrics
@@ -467,27 +464,23 @@ Show project metrics and estimated cost breakdown for requests, invocation count
```
Usage:
up metrics [<flags>] [<stage>]
up metrics [<flags>]
Flags:
-h, --help Output usage information.
-C, --chdir="." Change working directory.
-v, --verbose Enable verbose log output.
--format="text" Output formatter.
--version Show application version.
-s, --since="1M" Show logs since duration (30s, 5m, 2h, 1h30m, 3d, 1M).
Args:
[<stage>] Name of the stage.
-h, --help Output usage information.
-C, --chdir="." Change working directory.
-v, --verbose Enable verbose log output.
--format="text" Output formatter.
--version Show application version.
-s, --stage="staging" Target stage name.
-S, --since="1M" Show logs since duration (30s, 5m, 2h, 1h30m, 3d, 1M).
```

For example:

```
$ up metrics production -s 15d
$ up metrics -s production -S 15d
Requests: 13,653 ($0.01)
Duration min: 0ms
@@ -18,8 +18,8 @@ import (
func init() {
cmd := root.Command("logs", "Show log output.")
cmd.Example(`up logs`, "Show logs from the past hour.")
cmd.Example(`up logs -s 30m`, "Show logs from the past 30 minutes.")
cmd.Example(`up logs -s 5h`, "Show logs from the past 5 hours.")
cmd.Example(`up logs -S 30m`, "Show logs from the past 30 minutes.")
cmd.Example(`up logs -S 5h`, "Show logs from the past 5 hours.")
cmd.Example(`up logs -f`, "Show live log output.")
cmd.Example(`up logs error`, "Show error logs.")
cmd.Example(`up logs 'production (warn or error)'`, "Show 4xx and 5xx responses in production.")
@@ -38,7 +38,7 @@ func init() {

query := cmd.Arg("query", "Query pattern for filtering logs.").String()
follow := cmd.Flag("follow", "Follow or tail the live logs.").Short('f').Bool()
since := cmd.Flag("since", "Show logs since duration (30s, 5m, 2h, 1h30m, 3d, 1M).").Short('s').Default("1d").String()
since := cmd.Flag("since", "Show logs since duration (30s, 5m, 2h, 1h30m, 3d, 1M).").Short('S').Default("1d").String()
expand := cmd.Flag("expand", "Show expanded logs.").Short('e').Bool()

cmd.Action(func(_ *kingpin.ParseContext) error {
@@ -14,10 +14,10 @@ import (
func init() {
cmd := root.Command("metrics", "Show project metrics.")
cmd.Example(`up metrics`, "Show metrics for staging environment.")
cmd.Example(`up metrics production`, "Show metrics for production environment.")
cmd.Example(`up metrics -s production`, "Show metrics for production environment.")

stage := cmd.Arg("stage", "Name of the stage.").Default("staging").String()
since := cmd.Flag("since", "Show logs since duration (30s, 5m, 2h, 1h30m, 3d, 1M).").Short('s').Default("1M").String()
stage := cmd.Flag("stage", "Target stage name.").Short('s').Default("staging").String()
since := cmd.Flag("since", "Show logs since duration (30s, 5m, 2h, 1h30m, 3d, 1M).").Short('S').Default("1M").String()

cmd.Action(func(_ *kingpin.ParseContext) error {
c, p, err := root.Init()
@@ -20,11 +20,11 @@ func init() {
cmd.Example(`up url`, "Show the staging endpoint.")
cmd.Example(`up url --open`, "Open the staging endpoint in the browser.")
cmd.Example(`up url --copy`, "Copy the staging endpoint to the clipboard.")
cmd.Example(`up url production`, "Show the production endpoint.")
cmd.Example(`up url -o production`, "Open the production endpoint in the browser.")
cmd.Example(`up url -c production`, "Copy the production endpoint to the clipboard.")
cmd.Example(`up url -s production`, "Show the production endpoint.")
cmd.Example(`up url -o -s production`, "Open the production endpoint in the browser.")
cmd.Example(`up url -c -s production`, "Copy the production endpoint to the clipboard.")

stage := cmd.Arg("stage", "Name of the stage.").Default("staging").String()
stage := cmd.Flag("stage", "Target stage name.").Short('s').Default("staging").String()
open := cmd.Flag("open", "Open endpoint in the browser.").Short('o').Bool()
copy := cmd.Flag("copy", "Copy endpoint to the clipboard.").Short('c').Bool()

0 comments on commit e004cb4

Please sign in to comment.
You can’t perform that action at this time.