typesafehub / sbt-conductr

Typesafe ConductR plugin for sbt
Other
29 stars 22 forks source link

Support conduct logs --follow option #278

Closed TimMoore closed 6 years ago

TimMoore commented 7 years ago

The conduct logs CLI supports a handy --follow (or -f) option.

https://github.com/typesafehub/conductr-cli/blob/master/conductr_cli/conduct_main.py#L189-L196

Running conduct logs from sbt does not support this option:

https://github.com/typesafehub/sbt-conductr/blob/b3b000d5d31c8163bd75cd5e7819c2aa1aa78ba8/src/main/scala/com/lightbend/conductr/sbt/ConductRPlugin.scala#L684-L685

> conduct logs --help
usage: conduct logs [-h] [--scheme SCHEME] [--host HOST] [-i IP] [-p PORT]
                    [--base-path BASE_PATH] [-v] [--disable-instructions] [-q]
                    [--long-ids] [--api-version {1,2}]
                    [--settings-dir CLI_SETTINGS_DIR]
                    [--custom-settings-file CUSTOM_SETTINGS_FILE]
                    [--custom-plugins-dir CUSTOM_PLUGINS_DIR] [-n LINES] [-f]
                    [--utc]
                    bundle

positional arguments:
  bundle                The ID or name of the bundle

optional arguments:
  -h, --help            show this help message and exit
  --scheme SCHEME       The optional ConductR scheme, defaults to http
  --host HOST           The optional ConductR host
                        Defaults to one of the value in this order:
                        1. $CONDUCTR_HOST
                        2. $CONDUCTR_IP
                        3. IP address of the docker VM or
                        4. 127.0.0.1
  -i IP, --ip IP        The optional ConductR IP
                        Defaults to one of the value in this order:
                        1. $CONDUCTR_IP
                        2. IP address of the docker VM
                        3. 127.0.0.1
  -p PORT, --port PORT  The optional ConductR port
                        Defaults to $CONDUCTR_PORT or 9005
  --base-path BASE_PATH
                        The optional ConductR base path
                        Defaults to $DEFAULT_BASE_PATH or /
  -v, --verbose         Print detailed information of the command
  --disable-instructions
                        Disables further instruction output after the command has been succeeded
                        Defaults to False
  -q                    Prints affected bundle id on screen if enabled
                        Defaults to False
  --long-ids            Print long Bundle IDs
  --api-version {1,2}   Sets which ConductR api version to be used
                        Defaults to 2
  --settings-dir CLI_SETTINGS_DIR
                        Directory where ConductR CLI settings are stored
                        Defaults to /Users/tmoore/.conductr
  --custom-settings-file CUSTOM_SETTINGS_FILE
                        Configuration where custom settings for ConductR CLI are stored in HOCON format
                        Defaults to /Users/tmoore/.conductr/settings.conf
  --custom-plugins-dir CUSTOM_PLUGINS_DIR
                        Directory where custom plugins for ConductR CLI are stored
                        Defaults to /Users/tmoore/.conductr/plugins
  -n LINES, --lines LINES
                        The number of logs to fetch
                        Defaults to 10
  -f, --follow          Outputs log events as they occur. Analogous to UNIX's `tail -F`
  --utc                 Convert the date/time of the events to UTC
[success] Total time: 2 s, completed 11/07/2017 11:08:55 PM
> conduct logs -f hello-impl
[error] Usage: conduct logs --help
[error] conduct logs -f hello-impl
[error]                 ^
fsat commented 7 years ago

We should also support the additional command deploy, backup, restore, and also update the additional switches now exposed through load command.

fsat commented 7 years ago

SBT ConductR: Update with latest commands and switches from CLI

longshorej commented 7 years ago

The tricky thing about -f is that pressing CTRL-Cexits SBT. You can set Keys.cancelable in Global := true for your project, or we could do it in the plugin itself, but perhaps a user of the plugin doesn't want that setting. There isn't a way to set it per-task, it's a global SBT setting.

Another idea would be to poll for input in conduct logs and exit if the user presses q, and ensure connectInput is set for the conduct task.

Thoughts?

TimMoore commented 7 years ago

@longshorej the continuous file-watch features of sbt, Play and Lagom now all exit on Enter, so that's probably the best pattern to follow.