Skip to content

Commit

Permalink
allow line specifications in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
loganwright committed Dec 13, 2018
1 parent e38b249 commit 9fbaaa7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/CloudCommands/CloudGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct Logs: Command {
var options: [CommandOption] = [
.app,
.env,
.lines,
.showTimestamps,
]

Expand Down Expand Up @@ -113,7 +114,8 @@ struct LogsRunner: AuthorizedRunner {
// pod -- a specific pod
// timestamps -- whether to include timestamps
let timestamps = self.ctx.flag(.showTimestamps)
let query = "lines=200&timestamps=\(timestamps.description)"
let lines = self.ctx.options.value(.lines) ?? "200"
let query = "lines=\(lines)&timestamps=\(timestamps.description)"
let list = logs.list(query: query)
return list.map { list in
for log in list {
Expand Down
8 changes: 8 additions & 0 deletions Sources/CloudCommands/CommandOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ extension CommandOption {
"the slug associated with your app."
]
)

static let lines: CommandOption = .value(
name: "lines",
short: "l",
default: "200",
help: ["if passed, should show timestamps"]
)

static let showTimestamps: CommandOption = .flag(
name: "show-timestamps",
short: "t",
Expand Down

0 comments on commit 9fbaaa7

Please sign in to comment.