-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hermes: replace default JSON with human-readable output #796
Merged
Merged
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
885c39f
Added log_json flag to config
adizere a7309af
Merge branch 'master' into adi/v0.2_ux
adizere be0683f
Add missing JSON flag for CI workflow
adizere afb485e
One more toml config file
adizere 6c0f00f
Introduce custom-made EntryPoint
adizere 2e2dc0b
Tracing with custom writer to ensure stderr output. h/t @romac
adizere 573a5a9
JSON-aware output in conclude.rs
adizere 4f7284c
Enabled json output in e2e suite
adizere cbb189a
Switch to pretty formatter when JSON is off.
adizere 38353f0
Replaced the clumsy impl of json() with more direct approach h/t @romac.
adizere 4ee8d5e
More explicit json flag in e2e
adizere 0dd07d1
Merge branch 'master' into adi/v0.2_ux
adizere 287fbb6
changelog
adizere 3250dbc
Cleanup
romac cb7ce58
More cleanup
romac 9c5c96f
Use human-readable output for the final output result when JSON outpu…
romac a35a225
Enabled tracing filter by crate. Added custom pretty tracing component.
adizere 4dd8982
Replace /tx raw create-client/ with /create client/
adizere 6fcc666
Revert "Replace /tx raw create-client/ with /create client/"
adizere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
timeout = '10s' | ||
strategy = 'naive' | ||
log_level = 'info' | ||
log_json = false | ||
|
||
[[chains]] | ||
id = 'ibc-0' | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
timeout = '10s' | ||
strategy = 'naive' | ||
log_level = 'error' | ||
log_json = false | ||
|
||
[[chains]] | ||
id = 'ibc-0' | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
timeout = '10s' | ||
strategy = 'naive' | ||
log_level = 'error' | ||
log_json = false | ||
|
||
[[chains]] | ||
id = 'ibc-0' | ||
|
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 was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,109 @@ | ||
use std::path::PathBuf; | ||
|
||
use abscissa_core::command::Usage; | ||
use abscissa_core::{Command, Config, Configurable, FrameworkError, Options, Runnable}; | ||
|
||
/// Custom entry point for Hermes. | ||
/// | ||
/// Replaces `abscissa_core::EntryPoint` with custom-made flag (for JSON output). | ||
#[derive(Debug, Options)] | ||
pub struct EntryPoint<Cmd> | ||
where | ||
Cmd: Command + Runnable, | ||
{ | ||
/// Path to the configuration file | ||
#[options(short = "c", help = "path to configuration file")] | ||
pub config: Option<PathBuf>, | ||
|
||
/// Obtain help about the current command | ||
#[options(short = "h", help = "print help message")] | ||
pub help: bool, | ||
|
||
/// Toggle JSON output mode one verbosity setting | ||
#[options(short = "j", help = "enable JSON output")] | ||
pub json: bool, | ||
|
||
/// Subcommand to execute. | ||
/// | ||
/// The `command` option will delegate option parsing to the command type, | ||
/// starting at the first free argument. | ||
#[options(command)] | ||
pub command: Option<Cmd>, | ||
} | ||
|
||
impl<Cmd> EntryPoint<Cmd> | ||
where | ||
Cmd: Command + Runnable, | ||
{ | ||
/// Borrow the underlying command type or print usage info and exit | ||
fn command(&self) -> &Cmd { | ||
self.command | ||
.as_ref() | ||
.unwrap_or_else(|| Cmd::print_usage_and_exit(&[])) | ||
} | ||
} | ||
|
||
impl<Cmd> Runnable for EntryPoint<Cmd> | ||
where | ||
Cmd: Command + Runnable, | ||
{ | ||
fn run(&self) { | ||
self.command().run() | ||
} | ||
} | ||
|
||
impl<Cmd> Command for EntryPoint<Cmd> | ||
where | ||
Cmd: Command + Runnable, | ||
{ | ||
/// Name of this program as a string | ||
fn name() -> &'static str { | ||
"hermes" | ||
} | ||
|
||
/// Description of this program | ||
fn description() -> &'static str { | ||
Cmd::description() | ||
} | ||
|
||
/// Version of this program | ||
fn version() -> &'static str { | ||
Cmd::version() | ||
} | ||
|
||
/// Authors of this program | ||
fn authors() -> &'static str { | ||
Cmd::authors() | ||
} | ||
|
||
/// Get usage information for a particular subcommand (if available) | ||
fn subcommand_usage(command: &str) -> Option<Usage> { | ||
Cmd::subcommand_usage(command) | ||
} | ||
} | ||
|
||
impl<Cfg, Cmd> Configurable<Cfg> for EntryPoint<Cmd> | ||
where | ||
Cmd: Command + Configurable<Cfg> + Runnable, | ||
Cfg: Config, | ||
{ | ||
/// Path to the command's configuration file | ||
fn config_path(&self) -> Option<PathBuf> { | ||
match &self.config { | ||
// Use explicit `-c`/`--config` argument if passed | ||
Some(cfg) => Some(cfg.clone()), | ||
|
||
// Otherwise defer to the toplevel command's config path logic | ||
None => self.command.as_ref().and_then(|cmd| cmd.config_path()), | ||
} | ||
} | ||
|
||
/// Process the configuration after it has been loaded, potentially | ||
/// modifying it or returning an error if options are incompatible | ||
fn process_config(&self, config: Cfg) -> Result<Cfg, FrameworkError> { | ||
match &self.command { | ||
Some(cmd) => cmd.process_config(config), | ||
None => Ok(config), | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
timeout = '10s' | ||
strategy = 'naive' | ||
log_level = 'error' | ||
log_json = false | ||
|
||
[[chains]] | ||
id = 'chain_A' | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍