Skip to content

Commit

Permalink
improvement(dev): split --cmd by newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
thsig committed May 11, 2023
1 parent ac3b231 commit 7ed41e2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
16 changes: 10 additions & 6 deletions core/src/cli/command-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,17 @@ export class CommandLine extends TypedEventEmitter<CommandLineEvents> {
this.clear()
// Make sure it takes at most 2 seconds to auto-type the command.
const sleepMs = Math.min(Math.floor(2000 / line.length), 40)
for (const char of line) {
this.addCharacter(char)
this.commandLineCallback(commandLinePrefix + this.currentCommand)
await sleep(sleepMs)
// We split newlines into separate commands
const lines = line.trim().split(/[\r\n]+/)
for (const cmd of lines) {
for (const char of cmd) {
this.addCharacter(char)
this.commandLineCallback(commandLinePrefix + this.currentCommand)
await sleep(sleepMs)
}
await sleep(250)
this.handleReturn()
}
await sleep(250)
this.handleReturn()
this.commandLineCallback(commandLinePrefix + this.currentCommand)
}

Expand Down
1 change: 0 additions & 1 deletion core/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { PluginEventBroker } from "../plugin-context"
import { HandlerMonitor } from "../monitors/handler"
import { GraphResultFromTask } from "../graph/results"
import { PortForwardMonitor } from "../monitors/port-forward"
import { registerCleanupFunction } from "../util/util"
import { LogMonitor } from "../monitors/logs"
import { LoggerType, parseLogLevel } from "../logger/logger"
import { serveOpts } from "./serve"
Expand Down
7 changes: 6 additions & 1 deletion core/src/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ export class ServeCommand<
})
}

async action({ garden, log, cli, opts }: CommandParams<ServeCommandArgs, ServeCommandOpts>): Promise<CommandResult<R>> {
async action({
garden,
log,
cli,
opts
}: CommandParams<ServeCommandArgs, ServeCommandOpts>): Promise<CommandResult<R>> {
this.garden = garden
const loggedIn = this.garden?.isLoggedIn()
if (!loggedIn) {
Expand Down
1 change: 1 addition & 0 deletions docs/reference/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ This always takes the precedence over sync mode if there are any conflicts, i.e.
| `--forward` | | boolean | Create port forwards and leave process running after deploying. This is implied if any of --sync / --local or --logs are set.
| `--logs` | | boolean | Stream logs from the requested Deploy(s) (or services if using modules) during deployment, and leave the log streaming process running after deploying. Note: This option implies the --forward option.
| `--timestamps` | | boolean | Show timestamps with log output. Should be used with the &#x60;--logs&#x60; option (has no effect if that option is not used).
| `--port` | | number | The port number for the server to listen on.

#### Outputs

Expand Down

0 comments on commit 7ed41e2

Please sign in to comment.