diff --git a/.changelog/unreleased/improvements/ibc-relayer/1576-update-abscissa.md b/.changelog/unreleased/improvements/ibc-relayer/1576-update-abscissa.md new file mode 100644 index 0000000000..a4b5cc0ee5 --- /dev/null +++ b/.changelog/unreleased/improvements/ibc-relayer/1576-update-abscissa.md @@ -0,0 +1,5 @@ +- Update to abscissa framework version 0.6.0-beta.1, adding support for + `--help` flags in subcommands and improving help and usage printouts. + The `--version` option of the `create channel` subcommand has been renamed + to `--channel-version`, with the old name still supported as an alias. + ([#1576](https://github.com/informalsystems/ibc-rs/pull/1576)) diff --git a/Cargo.lock b/Cargo.lock index 37ed5a6f65..aafc8f333a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,37 +4,35 @@ version = 3 [[package]] name = "abscissa_core" -version = "0.5.2" +version = "0.6.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a07677093120a02583717b6dd1ef81d8de1e8d01bd226c83f0f9bdf3e56bb3a" +checksum = "1f5cf2609df76c3c3f00c710b0f60330aa5f48ae3fd4a9d3a0515c4e282045f1" dependencies = [ "abscissa_derive", + "arc-swap", "backtrace", "canonical-path", - "chrono", - "color-backtrace", - "generational-arena", - "gumdrop 0.7.0", - "libc", + "clap", + "color-eyre", + "fs-err", "once_cell", "regex", "secrecy", - "semver 0.9.0", + "semver", "serde", - "signal-hook 0.1.17", "termcolor", "toml", "tracing", "tracing-log", - "tracing-subscriber 0.1.6", + "tracing-subscriber 0.2.25", "wait-timeout", ] [[package]] name = "abscissa_derive" -version = "0.5.0" +version = "0.6.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f5722bc48763cb9d81d8427ca05b6aa2842f6632cf8e4c0a29eef9baececcc" +checksum = "a7ce86f8f9c77ef2fb491c86aff9f0b89f99dbdf3915e4317478744062e72613" dependencies = [ "darling", "ident_case", @@ -67,22 +65,13 @@ checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "aho-corasick" -version = "0.7.15" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -99,10 +88,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62e1f47f7dc0422027a4e370dd4548d4d66b26782e513e98dca1e689e058a80e" [[package]] -name = "arrayvec" -version = "0.5.2" +name = "arc-swap" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "c5d78ce20460b82d3fa150275ed9d55e21064fc7951177baacf86a145c4a4b1f" [[package]] name = "ascii" @@ -229,18 +218,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitvec" -version = "0.19.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55f93d0ef3363c364d5976646a38f04cf67cfe1d4c8d160cdea02cab2c116b33" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -339,7 +316,6 @@ dependencies = [ "num-integer", "num-traits", "serde", - "time 0.1.43", "winapi", ] @@ -351,9 +327,9 @@ checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e" [[package]] name = "clap" -version = "3.0.0-beta.4" +version = "3.0.0-beta.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcd70aa5597dbc42f7217a543f9ef2768b2ef823ba29036072d30e1d88e98406" +checksum = "feff3878564edb93745d58cf63e17b63f24142506e7a20c87a5521ed7bfb1d63" dependencies = [ "atty", "bitflags", @@ -361,17 +337,17 @@ dependencies = [ "indexmap", "lazy_static", "os_str_bytes", - "strsim 0.10.0", + "strsim", "termcolor", "textwrap", - "vec_map", + "unicase", ] [[package]] name = "clap_derive" -version = "3.0.0-beta.4" +version = "3.0.0-beta.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b5bb0d655624a0b8770d1c178fb8ffcb1f91cc722cb08f451e3dc72465421ac" +checksum = "8b15c6b4f786ffb6192ffe65a36855bc1fc2444bcd0945ae16748dcd6ed7d0d3" dependencies = [ "heck", "proc-macro-error", @@ -380,17 +356,6 @@ dependencies = [ "syn", ] -[[package]] -name = "color-backtrace" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d13f1078cc63c791d0deba0dd43db37c9ec02b311f10bed10b577016f3a957" -dependencies = [ - "atty", - "backtrace", - "termcolor", -] - [[package]] name = "color-eyre" version = "0.5.11" @@ -489,6 +454,30 @@ dependencies = [ "crossbeam-utils 0.8.5", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils 0.8.5", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils 0.8.5", + "lazy_static", + "memoffset", + "scopeguard", +] + [[package]] name = "crossbeam-utils" version = "0.7.2" @@ -572,9 +561,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.10.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" +checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ "darling_core", "darling_macro", @@ -582,23 +571,23 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.10.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" +checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim 0.9.3", + "strsim", "syn", ] [[package]] name = "darling_macro" -version = "0.10.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ "darling_core", "quote", @@ -817,10 +806,10 @@ dependencies = [ ] [[package]] -name = "funty" -version = "1.1.0" +name = "fs-err" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +checksum = "5ebd3504ad6116843b8375ad70df74e7bfe83cac77a1f3fe73200c844d43bfe0" [[package]] name = "futures" @@ -911,15 +900,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generational-arena" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d3b771574f62d0548cee0ad9057857e9fc25d7a3335f140c84f6acd0bf601" -dependencies = [ - "cfg-if 0.1.10", -] - [[package]] name = "generic-array" version = "0.14.4" @@ -973,33 +953,13 @@ dependencies = [ "subtle", ] -[[package]] -name = "gumdrop" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee50908bc1beeac1f2902e0b4e0cd0d844e716f5ebdc6f0cfc1163fe5e10bcde" -dependencies = [ - "gumdrop_derive 0.7.0", -] - [[package]] name = "gumdrop" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46571f5d540478cf70d2a42dd0d6d8e9f4b9cc7531544b93311e657b86568a0b" dependencies = [ - "gumdrop_derive 0.8.0", -] - -[[package]] -name = "gumdrop_derive" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90454ce4de40b7ca6a8968b5ef367bdab48413962588d0d2b1638d60090c35d7" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "gumdrop_derive", ] [[package]] @@ -1273,8 +1233,6 @@ version = "0.9.0" dependencies = [ "bytes", "chrono", - "clap", - "clap_derive", "env_logger", "flex-error", "ibc-proto", @@ -1373,7 +1331,7 @@ dependencies = [ "prost-types", "retry", "ripemd160", - "semver 1.0.4", + "semver", "serde", "serde_cbor", "serde_derive", @@ -1405,13 +1363,13 @@ version = "0.9.0" dependencies = [ "abscissa_core", "atty", + "clap", "color-eyre", "crossbeam-channel 0.5.1", "dirs-next", "eyre", "flex-error", "futures", - "gumdrop 0.7.0", "hex", "ibc", "ibc-proto", @@ -1427,7 +1385,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "signal-hook 0.3.10", + "signal-hook", "subtle-encoding", "tendermint", "tendermint-light-client", @@ -1582,19 +1540,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lexical-core" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" -dependencies = [ - "arrayvec", - "bitflags", - "cfg-if 1.0.0", - "ryu", - "static_assertions", -] - [[package]] name = "libc" version = "0.2.108" @@ -1651,9 +1596,18 @@ checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "memoffset" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg", +] [[package]] name = "mime" @@ -1671,6 +1625,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.4.4" @@ -1705,13 +1665,16 @@ dependencies = [ [[package]] name = "modelator" -version = "0.2.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c107a31c31b93540d2f058e24695b1c6a101b5cca01ab214db04a4d471e9f9e0" +checksum = "d7823be4eb9e74af36fcd8386c623de4d8200d4e719f4e2807a09ce7ab7b032c" dependencies = [ "clap", "hex", + "lazy_static", "nom", + "rayon", + "regex", "serde", "serde_json", "sha2", @@ -1760,14 +1723,12 @@ dependencies = [ [[package]] name = "nom" -version = "6.2.1" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c5c51b9083a3c620fa67a2a635d1ce7d95b897e957d6b28ff9a5da960a103a6" +checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" dependencies = [ - "bitvec", - "funty", - "lexical-core", "memchr", + "minimal-lexical", "version_check", ] @@ -1937,17 +1898,11 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6acbef58a60fe69ab50510a55bc8cdd4d6cf2283d27ad338f54cb52747a9cf2d" - -[[package]] -name = "owning_ref" -version = "0.4.1" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" +checksum = "addaa943333a514159c80c97ff4a93306530d965d27e139188283cd13e06a799" dependencies = [ - "stable_deref_trait", + "memchr", ] [[package]] @@ -1977,7 +1932,7 @@ dependencies = [ "instant", "libc", "redox_syscall", - "smallvec 1.7.0", + "smallvec", "winapi", ] @@ -2185,12 +2140,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" - [[package]] name = "rand" version = "0.7.3" @@ -2272,6 +2221,31 @@ dependencies = [ "rand_core 0.6.3", ] +[[package]] +name = "rayon" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +dependencies = [ + "crossbeam-channel 0.5.1", + "crossbeam-deque", + "crossbeam-utils 0.8.5", + "lazy_static", + "num_cpus", +] + [[package]] name = "redox_syscall" version = "0.2.10" @@ -2293,9 +2267,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.6" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "aho-corasick", "memchr", @@ -2378,7 +2352,7 @@ dependencies = [ "serde_json", "sha1", "threadpool", - "time 0.3.2", + "time", "tiny_http", "url", ] @@ -2557,9 +2531,9 @@ dependencies = [ [[package]] name = "secrecy" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9182278ed645df3477a9c27bfee0621c621aa16f6972635f7f795dae3d81070f" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" dependencies = [ "serde", "zeroize", @@ -2590,26 +2564,13 @@ dependencies = [ [[package]] name = "semver" -version = "0.9.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" dependencies = [ - "semver-parser", "serde", ] -[[package]] -name = "semver" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "1.0.130" @@ -2746,16 +2707,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "signal-hook" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" -dependencies = [ - "libc", - "signal-hook-registry", -] - [[package]] name = "signal-hook" version = "0.3.10" @@ -2797,15 +2748,6 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" -[[package]] -name = "smallvec" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - [[package]] name = "smallvec" version = "1.7.0" @@ -2843,24 +2785,12 @@ dependencies = [ "der", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" - [[package]] name = "strsim" version = "0.10.0" @@ -2905,12 +2835,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "tempfile" version = "3.2.0" @@ -3051,7 +2975,7 @@ checksum = "a6df4b2bc95b5c65ab661c8ab0e0054dd61b4e4c4edd53c2831c317e40042eac" dependencies = [ "chrono", "ed25519-dalek", - "gumdrop 0.8.0", + "gumdrop", "serde", "serde_json", "simple-error", @@ -3126,16 +3050,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "time" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "time" version = "0.3.2" @@ -3437,30 +3351,13 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-subscriber" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "192ca16595cdd0661ce319e8eede9c975f227cdaabc4faaefdc256f43d852e45" -dependencies = [ - "ansi_term 0.11.0", - "chrono", - "lazy_static", - "matchers 0.0.1", - "owning_ref", - "regex", - "smallvec 0.6.14", - "tracing-core", - "tracing-log", -] - [[package]] name = "tracing-subscriber" version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" dependencies = [ - "ansi_term 0.12.1", + "ansi_term", "chrono", "lazy_static", "matchers 0.0.1", @@ -3468,7 +3365,7 @@ dependencies = [ "serde", "serde_json", "sharded-slab", - "smallvec 1.7.0", + "smallvec", "thread_local", "tracing", "tracing-core", @@ -3482,14 +3379,14 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7507ec620f809cdf07cccb5bc57b13069a88031b795efd4079b1c71b66c1613d" dependencies = [ - "ansi_term 0.12.1", + "ansi_term", "lazy_static", "matchers 0.1.0", "regex", "serde", "serde_json", "sharded-slab", - "smallvec 1.7.0", + "smallvec", "thread_local", "tracing", "tracing-core", @@ -3643,12 +3540,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.3" @@ -3830,12 +3721,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "wyz" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" - [[package]] name = "zeroize" version = "1.4.3" diff --git a/e2e/e2e/connection.py b/e2e/e2e/connection.py index 876f2917d3..834cfb6440 100644 --- a/e2e/e2e/connection.py +++ b/e2e/e2e/connection.py @@ -316,7 +316,7 @@ def passive_connection_init_then_start(c: Config, # 2. start hermes proc = relayer.start(c) - sleep(2.0) + sleep(10.0) # 3. wait for connection handshake to finish and verify connection state on both chains verify_state(c, ibc1, ibc0, ibc1_conn_id_a) @@ -337,7 +337,7 @@ def passive_connection_try_then_start(c: Config, # 2. start hermes proc = relayer.start(c) - sleep(2.0) + sleep(10.0) # 3. wait for connection handshake to finish and verify connection state on both chains verify_state(c, ibc1, ibc0, ibc1_conn_id_a) diff --git a/modules/Cargo.toml b/modules/Cargo.toml index 4263988e29..17242868e0 100644 --- a/modules/Cargo.toml +++ b/modules/Cargo.toml @@ -59,15 +59,11 @@ optional = true env_logger = "0.9.0" tracing-subscriber = { version = "0.3.2", features = ["fmt", "env-filter", "json"]} test-log = { version = "0.2.8", features = ["trace"] } -modelator = "0.2.1" +modelator = "0.3.2" sha2 = { version = "0.9.8" } tendermint-rpc = { version = "=0.23.1", features = ["http-client", "websocket-client"] } tendermint-testgen = { version = "=0.23.1" } # Needed for generating (synthetic) light blocks. -# pin clap to avoid miscompilations with modelator -clap = "=3.0.0-beta.4" -clap_derive = "=3.0.0-beta.4" - [[test]] name = "mbt" path = "tests/mbt.rs" diff --git a/modules/src/core/ics04_channel/channel.rs b/modules/src/core/ics04_channel/channel.rs index b4e27ee4e7..15e0ad946a 100644 --- a/modules/src/core/ics04_channel/channel.rs +++ b/modules/src/core/ics04_channel/channel.rs @@ -353,7 +353,7 @@ impl FromStr for Order { type Err = Error; fn from_str(s: &str) -> Result { - match s.to_lowercase().as_str() { + match s.to_lowercase().trim_start_matches("order_") { "uninitialized" => Ok(Self::None), "unordered" => Ok(Self::Unordered), "ordered" => Ok(Self::Ordered), diff --git a/modules/tests/mbt.rs b/modules/tests/mbt.rs index 2568ef418d..1c505dbc21 100644 --- a/modules/tests/mbt.rs +++ b/modules/tests/mbt.rs @@ -2,7 +2,10 @@ extern crate alloc; mod runner; -use modelator::{run_tla_steps, ModelChecker, TestError}; +use modelator::{ + model::checker::{ModelChecker, ModelCheckerRuntime}, + Error, +}; use runner::IbcTestRunner; #[test] @@ -14,14 +17,14 @@ fn mbt() { } } -fn run_tests() -> Result<(), TestError> { +fn run_tests() -> Result<(), Error> { // run the test let tla_tests_file = "tests/support/model_based/IBCTests.tla"; let tla_config_file = "tests/support/model_based/IBCTests.cfg"; - let mut opts = modelator::Options::default(); - opts.model_checker_options.model_checker = ModelChecker::Tlc; + let runtime = modelator::ModelatorRuntime::default() + .model_checker_runtime(ModelCheckerRuntime::default().model_checker(ModelChecker::Tlc)); let mut runner = IbcTestRunner::new(); - run_tla_steps(tla_tests_file, tla_config_file, &opts, &mut runner)?; + runtime.run_tla_steps(tla_tests_file, tla_config_file, &mut runner)?; Ok(()) } diff --git a/relayer-cli/Cargo.toml b/relayer-cli/Cargo.toml index 37f6405d3d..c17833f946 100644 --- a/relayer-cli/Cargo.toml +++ b/relayer-cli/Cargo.toml @@ -32,7 +32,7 @@ ibc-proto = { version = "0.13.0", path = "../proto" } ibc-telemetry = { version = "0.9.0", path = "../telemetry", optional = true } ibc-relayer-rest = { version = "0.9.0", path = "../relayer-rest", optional = true } -gumdrop = { version = "0.7", features = ["default_expr"] } +clap = { version = "=3.0.0-beta.5" } serde = { version = "1.0", features = ["serde_derive"] } tokio = { version = "1.0", features = ["full"] } tracing = "0.1.29" @@ -71,9 +71,10 @@ version = "=0.23.1" features = ["unstable"] [dependencies.abscissa_core] -version = "0.5.2" +version = "0.6.0-beta.1" +features = ["options"] [dev-dependencies] -abscissa_core = { version = "0.5.2", features = ["testing"] } +abscissa_core = { version = "0.6.0-beta.1", features = ["testing"] } once_cell = "1.8" -regex = "1" +regex = "1.5" diff --git a/relayer-cli/src/application.rs b/relayer-cli/src/application.rs index 6c16de3bde..ff478e148d 100644 --- a/relayer-cli/src/application.rs +++ b/relayer-cli/src/application.rs @@ -2,16 +2,17 @@ use std::path::PathBuf; -use abscissa_core::terminal::component::Terminal; use abscissa_core::{ application::{self, AppCell}, component::Component, - config, Application, Configurable, FrameworkError, FrameworkErrorKind, StandardPaths, + config::{self, CfgCell}, + terminal::component::Terminal, + terminal::ColorChoice, + Application, Configurable, FrameworkError, FrameworkErrorKind, StandardPaths, }; use ibc_relayer::config::Config; use crate::{ - commands::CliCmd, components::{JsonTracing, PrettyTracing}, config::validate_config, entry::EntryPoint, @@ -23,27 +24,22 @@ pub static APPLICATION: AppCell = AppCell::new(); /// Obtain a read-only (multi-reader) lock on the application state. /// /// Panics if the application state has not been initialized. -pub fn app_reader() -> application::lock::Reader { - APPLICATION.read() -} - -/// Obtain an exclusive mutable lock on the application state. -pub fn app_writer() -> application::lock::Writer { - APPLICATION.write() +pub fn app_reader() -> &'static CliApp { + &APPLICATION } /// Obtain a read-only (multi-reader) lock on the application configuration. /// /// Panics if the application configuration has not been loaded. -pub fn app_config() -> config::Reader { - config::Reader::new(&APPLICATION) +pub fn app_config() -> config::Reader { + APPLICATION.config.read() } /// Cli Application #[derive(Debug)] pub struct CliApp { /// Application configuration. - config: Option, + config: CfgCell, /// Application state. state: application::State, @@ -62,7 +58,7 @@ pub struct CliApp { impl Default for CliApp { fn default() -> Self { Self { - config: None, + config: CfgCell::default(), state: application::State::default(), json_output: false, config_path: None, @@ -84,7 +80,7 @@ impl CliApp { impl Application for CliApp { /// Entrypoint command for this application. - type Cmd = EntryPoint; + type Cmd = EntryPoint; /// Application configuration. type Cfg = Config; @@ -93,8 +89,8 @@ impl Application for CliApp { type Paths = StandardPaths; /// Accessor for application configuration. - fn config(&self) -> &Config { - self.config.as_ref().expect("config not loaded") + fn config(&self) -> config::Reader { + self.config.read() } /// Borrow the application state immutably. @@ -102,19 +98,15 @@ impl Application for CliApp { &self.state } - /// Borrow the application state mutably. - fn state_mut(&mut self) -> &mut application::State { - &mut self.state - } - /// Register all components used by this application. /// /// If you would like to add additional components to your application /// beyond the default ones provided by the framework, this is the place /// to do so. fn register_components(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> { - let components = self.framework_components(command)?; - self.state.components.register(components) + let framework_components = self.framework_components(command)?; + let mut app_components = self.state.components_mut(); + app_components.register(framework_components) } /// Post-configuration lifecycle callback. @@ -126,7 +118,8 @@ impl Application for CliApp { use crate::config::Diagnostic; // Configure components - self.state.components.after_config(&config)?; + let mut components = self.state.components_mut(); + components.after_config(&config)?; if let Err(diagnostic) = validate_config(&config) { match diagnostic { @@ -139,7 +132,7 @@ impl Application for CliApp { } }; - self.config = Some(config); + self.config.set_once(config); Ok(()) } @@ -188,4 +181,10 @@ impl Application for CliApp { Ok(vec![Box::new(terminal), Box::new(tracing)]) } } + + // Disable color support due to + // https://github.com/iqlusioninc/abscissa/issues/589 + fn term_colors(&self, _command: &Self::Cmd) -> ColorChoice { + ColorChoice::Never + } } diff --git a/relayer-cli/src/commands.rs b/relayer-cli/src/commands.rs index c2db0bf156..ad91af9534 100644 --- a/relayer-cli/src/commands.rs +++ b/relayer-cli/src/commands.rs @@ -7,9 +7,8 @@ use std::path::PathBuf; -use abscissa_core::{ - config::Override, Command, Configurable, FrameworkError, Help, Options, Runnable, -}; +use abscissa_core::{config::Override, Clap, Command, Configurable, FrameworkError, Runnable}; +use clap::AppSettings::Hidden; use tracing::{error, info}; use crate::DEFAULT_CONFIG_PATH; @@ -40,59 +39,58 @@ pub fn default_config_file() -> Option { } /// Cli Subcommands -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Clap, Debug, Runnable)] pub enum CliCmd { - /// The `help` subcommand - #[options(help = "Get usage information")] - Help(Help), - /// The `config` subcommand - #[options(help = "Validate Hermes configuration file")] + #[clap(subcommand, about = "Validate Hermes configuration file")] Config(ConfigCmd), /// The `keys` subcommand - #[options(help = "Manage keys in the relayer for each chain")] + #[clap(subcommand, about = "Manage keys in the relayer for each chain")] Keys(KeysCmd), /// The `create` subcommand - #[options(help = "Create objects (client, connection, or channel) on chains")] + #[clap( + subcommand, + about = "Create objects (client, connection, or channel) on chains" + )] Create(CreateCmds), /// The `update` subcommand - #[options(help = "Update objects (clients) on chains")] + #[clap(subcommand, about = "Update objects (clients) on chains")] Update(UpdateCmds), /// The `upgrade` subcommand - #[options(help = "Upgrade objects (clients) after chain upgrade")] + #[clap(subcommand, about = "Upgrade objects (clients) after chain upgrade")] Upgrade(UpgradeCmds), /// The `start` subcommand - #[options(help = "Start the relayer in multi-chain mode. \ + #[clap(about = "Start the relayer in multi-chain mode. \ Relays packets and open handshake messages between all chains in the config.")] Start(StartCmd), /// The `query` subcommand - #[options(help = "Query objects from the chain")] + #[clap(subcommand, about = "Query objects from the chain")] Query(QueryCmd), /// The `tx` subcommand - #[options(help = "Create and send IBC transactions")] + #[clap(subcommand, about = "Create and send IBC transactions")] Tx(TxCmd), /// The `listen` subcommand - #[options(help = "Listen to and display IBC events emitted by a chain")] + #[clap(about = "Listen to and display IBC events emitted by a chain")] Listen(ListenCmd), /// The `misbehaviour` subcommand - #[options(help = "Listen to client update IBC events and handles misbehaviour")] + #[clap(about = "Listen to client update IBC events and handles misbehaviour")] Misbehaviour(MisbehaviourCmd), - /// The `version` subcommand - #[options(help = "Display version information")] + /// The `version` subcommand, retained for backward compatibility. + #[clap(setting(Hidden))] Version(VersionCmd), /// The `health` subcommand - #[options(help = "Performs a health check of all chains in the the config")] + #[clap(about = "Performs a health check of all chains in the the config")] HealthCheck(HealthCheckCmd), } @@ -135,7 +133,7 @@ impl Configurable for CliCmd { fn process_config(&self, mut config: Config) -> Result { // Alter the memo for all chains to include a suffix with Hermes build details let web = "https://hermes.informal.systems"; - let suffix = format!("{} {} ({})", CliCmd::name(), CliCmd::version(), web); + let suffix = format!("{} {} ({})", CliCmd::name(), clap::crate_version!(), web); for ccfg in config.chains.iter_mut() { ccfg.memo_prefix.apply_suffix(&suffix); } diff --git a/relayer-cli/src/commands/config.rs b/relayer-cli/src/commands/config.rs index 4da3c9b0f9..31a0fdf3ba 100644 --- a/relayer-cli/src/commands/config.rs +++ b/relayer-cli/src/commands/config.rs @@ -1,19 +1,13 @@ //! `config` subcommand -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; mod validate; /// `config` subcommand -/// -/// The `Options` proc macro generates an option parser based on the struct -/// definition, and is defined in the `gumdrop` crate. See their documentation -/// for a more comprehensive example: -/// -/// -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum ConfigCmd { /// The `config validate` subcommand - #[options(help = "validate the relayer configuration")] + #[clap(about = "validate the relayer configuration")] Validate(validate::ValidateCmd), } diff --git a/relayer-cli/src/commands/config/validate.rs b/relayer-cli/src/commands/config/validate.rs index 9cf61b9236..9fae548698 100644 --- a/relayer-cli/src/commands/config/validate.rs +++ b/relayer-cli/src/commands/config/validate.rs @@ -1,10 +1,10 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use crate::conclude::Output; use crate::config; use crate::prelude::*; -#[derive(Command, Debug, Options)] +#[derive(Command, Debug, Clap)] pub struct ValidateCmd {} impl Runnable for ValidateCmd { diff --git a/relayer-cli/src/commands/create.rs b/relayer-cli/src/commands/create.rs index 013d6ac1e7..5e0f777992 100644 --- a/relayer-cli/src/commands/create.rs +++ b/relayer-cli/src/commands/create.rs @@ -1,5 +1,5 @@ //! `create` subcommand -use abscissa_core::{Command, Help, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use crate::commands::create::channel::CreateChannelCommand; use crate::commands::create::connection::CreateConnectionCommand; @@ -9,21 +9,17 @@ mod channel; mod connection; /// `create` subcommands -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum CreateCmds { - /// Generic `help` - #[options(help = "Get usage information")] - Help(Help), - /// Subcommand for creating a `client` - #[options(help = "Create a new IBC client")] + #[clap(about = "Create a new IBC client")] Client(TxCreateClientCmd), /// Subcommand for creating a `connection` - #[options(help = "Create a new connection between two chains")] + #[clap(about = "Create a new connection between two chains")] Connection(CreateConnectionCommand), /// Subcommand for creating a `channel` - #[options(help = "Create a new channel between two chains")] + #[clap(about = "Create a new channel between two chains")] Channel(CreateChannelCommand), } diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 55f6e28162..9256f5ca8f 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -1,4 +1,5 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; +use clap::AppSettings; use ibc::core::ics02_client::client_state::ClientState; use ibc::core::ics03_connection::connection::IdentifiedConnectionEnd; @@ -15,44 +16,53 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc_relayer::config::default::connection_delay; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] +#[clap(setting(AppSettings::DisableVersionFlag))] pub struct CreateChannelCommand { - #[options( - free, - required, - help = "identifier of the side `a` chain for the new channel" + #[clap( + required = true, + about = "identifier of the side `a` chain for the new channel" )] chain_a_id: ChainId, - #[options( - free, - help = "identifier of the side `b` chain for the new channel (optional)" - )] + #[clap(about = "identifier of the side `b` chain for the new channel (optional)")] chain_b_id: Option, - #[options( - help = "identifier of the connection on chain `a` to use in creating the new channel" + #[clap( + short, + long, + about = "identifier of the connection on chain `a` to use in creating the new channel" )] connection_a: Option, - #[options( - no_short, - required, - help = "identifier of the side `a` port for the new channel" + #[clap( + long, + required = true, + about = "identifier of the side `a` port for the new channel" )] port_a: PortId, - #[options( - no_short, - required, - help = "identifier of the side `b` port for the new channel" + #[clap( + long, + required = true, + about = "identifier of the side `b` port for the new channel" )] port_b: PortId, - #[options(help = "the channel ordering, valid options 'unordered' (default) and 'ordered'")] + #[clap( + short, + long, + about = "the channel ordering, valid options 'unordered' (default) and 'ordered'", + default_value_t + )] order: Order, - #[options(help = "the version for the new channel")] + #[clap( + short, + long = "channel-version", + alias = "version", + about = "the version for the new channel" + )] version: Option, } diff --git a/relayer-cli/src/commands/create/connection.rs b/relayer-cli/src/commands/create/connection.rs index 622a5ee22e..d6aa413fc0 100644 --- a/relayer-cli/src/commands/create/connection.rs +++ b/relayer-cli/src/commands/create/connection.rs @@ -1,6 +1,6 @@ use core::time::Duration; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use ibc::core::ics02_client::client_state::ClientState; use ibc::core::ics24_host::identifier::{ChainId, ClientId}; @@ -13,34 +13,33 @@ use crate::cli_utils::{spawn_chain_runtime, ChainHandlePair}; use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct CreateConnectionCommand { - #[options( - free, - required, - help = "identifier of the side `a` chain for the new connection" + #[clap( + required = true, + about = "identifier of the side `a` chain for the new connection" )] chain_a_id: ChainId, - #[options(free, help = "identifier of the side `b` chain for the new connection")] + #[clap(about = "identifier of the side `b` chain for the new connection")] chain_b_id: Option, - #[options( - help = "identifier of client hosted on chain `a`; default: None (creates a new client)", - no_short + #[clap( + long, + about = "identifier of client hosted on chain `a`; default: None (creates a new client)" )] client_a: Option, - #[options( - help = "identifier of client hosted on chain `b`; default: None (creates a new client)", - no_short + #[clap( + long, + about = "identifier of client hosted on chain `b`; default: None (creates a new client)" )] client_b: Option, - #[options( - help = "delay period parameter for the new connection (seconds)", - default = "0", - no_short + #[clap( + long, + about = "delay period parameter for the new connection (seconds)", + default_value = "0" )] delay: u64, } diff --git a/relayer-cli/src/commands/health.rs b/relayer-cli/src/commands/health.rs index 8fc760fb3d..3cd42b63b4 100644 --- a/relayer-cli/src/commands/health.rs +++ b/relayer-cli/src/commands/health.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use tokio::runtime::Runtime as TokioRuntime; use ibc_relayer::chain::{ChainEndpoint, CosmosSdkChain, HealthCheck::*}; @@ -8,7 +8,7 @@ use ibc_relayer::chain::{ChainEndpoint, CosmosSdkChain, HealthCheck::*}; use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct HealthCheckCmd {} impl Runnable for HealthCheckCmd { diff --git a/relayer-cli/src/commands/keys.rs b/relayer-cli/src/commands/keys.rs index 56dc320407..7f51925d39 100644 --- a/relayer-cli/src/commands/keys.rs +++ b/relayer-cli/src/commands/keys.rs @@ -1,5 +1,5 @@ //! `keys` subcommand -use abscissa_core::{Command, Help, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; mod add; mod delete; @@ -7,25 +7,21 @@ mod list; mod restore; /// `keys` subcommand -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum KeysCmd { - /// The `help` subcommand - #[options(help = "Get usage information")] - Help(Help), - /// The `keys add` subcommand - #[options(help = "Adds a key to a configured chain")] + #[clap(about = "Adds a key to a configured chain")] Add(add::KeysAddCmd), /// The `keys delete` subcommand - #[options(help = "Delete key(s) from a configured chain")] + #[clap(about = "Delete key(s) from a configured chain")] Delete(delete::KeysDeleteCmd), /// The `keys list` subcommand - #[options(help = "List keys configured on a chain")] + #[clap(about = "List keys configured on a chain")] List(list::KeysListCmd), /// The `keys restore` subcommand - #[options(help = "restore a key to a configured chain using a mnemonic")] + #[clap(about = "restore a key to a configured chain using a mnemonic")] Restore(restore::KeyRestoreCmd), } diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index e830fbc8cd..88b86143be 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -4,7 +4,7 @@ use std::{ path::{Path, PathBuf}, }; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use ibc::core::ics24_host::identifier::ChainId; use ibc_relayer::{ @@ -15,24 +15,26 @@ use ibc_relayer::{ use crate::application::app_config; use crate::conclude::Output; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct KeysAddCmd { - #[options(free, required, help = "identifier of the chain")] + #[clap(required = true, about = "identifier of the chain")] chain_id: ChainId, - #[options(short = "f", required, help = "path to the key file")] + #[clap(short = 'f', long, required = true, about = "path to the key file")] file: PathBuf, - #[options( - short = "n", - help = "name of the key (defaults to the `key_name` defined in the config)" + #[clap( + short = 'n', + long, + about = "name of the key (defaults to the `key_name` defined in the config)" )] name: Option, - #[options( - short = "p", - help = "derivation path for this key", - default = "m/44'/118'/0'/0/0" + #[clap( + short = 'p', + long, + about = "derivation path for this key", + default_value = "m/44'/118'/0'/0/0" )] hd_path: String, } diff --git a/relayer-cli/src/commands/keys/delete.rs b/relayer-cli/src/commands/keys/delete.rs index ed395a8f1e..4c4d601f27 100644 --- a/relayer-cli/src/commands/keys/delete.rs +++ b/relayer-cli/src/commands/keys/delete.rs @@ -1,4 +1,4 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use ibc::core::ics24_host::identifier::ChainId; use ibc_relayer::{ @@ -9,15 +9,15 @@ use ibc_relayer::{ use crate::application::app_config; use crate::conclude::Output; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct KeysDeleteCmd { - #[options(free, required, help = "identifier of the chain")] + #[clap(required = true, about = "identifier of the chain")] chain_id: ChainId, - #[options(short = "n", help = "name of the key")] + #[clap(short = 'n', long, about = "name of the key")] name: Option, - #[options(short = "a", help = "delete all keys")] + #[clap(short = 'a', long, about = "delete all keys")] all: bool, } diff --git a/relayer-cli/src/commands/keys/list.rs b/relayer-cli/src/commands/keys/list.rs index 091786f7c7..a3e266ee2e 100644 --- a/relayer-cli/src/commands/keys/list.rs +++ b/relayer-cli/src/commands/keys/list.rs @@ -1,6 +1,6 @@ use alloc::collections::btree_map::BTreeMap as HashMap; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use ibc::core::ics24_host::identifier::ChainId; use ibc_relayer::{ @@ -11,9 +11,9 @@ use ibc_relayer::{ use crate::conclude::Output; use crate::{application::app_config, conclude::json}; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct KeysListCmd { - #[options(free, required, help = "identifier of the chain")] + #[clap(required = true, about = "identifier of the chain")] chain_id: ChainId, } diff --git a/relayer-cli/src/commands/keys/restore.rs b/relayer-cli/src/commands/keys/restore.rs index 37acfe3089..21e65cfb7d 100644 --- a/relayer-cli/src/commands/keys/restore.rs +++ b/relayer-cli/src/commands/keys/restore.rs @@ -1,6 +1,6 @@ use core::str::FromStr; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use ibc::core::ics24_host::identifier::ChainId; use ibc_relayer::{ @@ -11,24 +11,31 @@ use ibc_relayer::{ use crate::application::app_config; use crate::conclude::Output; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct KeyRestoreCmd { - #[options(free, required, help = "identifier of the chain")] + #[clap(required = true, about = "identifier of the chain")] chain_id: ChainId, - #[options(short = "m", required, help = "mnemonic to restore the key from")] + #[clap( + short = 'm', + long, + required = true, + about = "mnemonic to restore the key from" + )] mnemonic: String, - #[options( - short = "n", - help = "name of the key (defaults to the `key_name` defined in the config)" + #[clap( + short = 'n', + long, + about = "name of the key (defaults to the `key_name` defined in the config)" )] name: Option, - #[options( - short = "p", - help = "derivation path for this key", - default = "m/44'/118'/0'/0/0" + #[clap( + short = 'p', + long, + about = "derivation path for this key", + default_value = "m/44'/118'/0'/0/0" )] hd_path: String, } diff --git a/relayer-cli/src/commands/listen.rs b/relayer-cli/src/commands/listen.rs index baa0e54a60..8a6265d09f 100644 --- a/relayer-cli/src/commands/listen.rs +++ b/relayer-cli/src/commands/listen.rs @@ -2,7 +2,8 @@ use alloc::sync::Arc; use core::{fmt, ops::Deref, str::FromStr}; use std::thread; -use abscissa_core::{application::fatal_error, Command, Options, Runnable}; +use abscissa_core::{application::fatal_error, Runnable}; +use clap::{App, Arg, ArgMatches, Args, FromArgMatches}; use itertools::Itertools; use tokio::runtime::Runtime as TokioRuntime; use tracing::{error, info}; @@ -46,7 +47,7 @@ impl fmt::Display for EventFilter { } impl FromStr for EventFilter { - type Err = Box; + type Err = Box; fn from_str(s: &str) -> Result { match s { @@ -57,14 +58,12 @@ impl FromStr for EventFilter { } } -#[derive(Command, Debug, Options)] +#[derive(Debug)] pub struct ListenCmd { /// Identifier of the chain to listen for events from - #[options(free)] chain_id: ChainId, - /// Add an event type to listen for, can be repeated. Listen for all events by default (available: Tx, NewBlock) - #[options(short = "e", long = "event", meta = "EVENT")] + /// Event types to listen for events: Vec, } @@ -86,6 +85,69 @@ impl ListenCmd { } } +// Can't derive Clap: a Vec struct field is translated by clap_derive to an +// arg with multiple_values(true), not multiple_occurrences(true). +// Implement all the necessary traits manually instead. +// See https://github.com/clap-rs/clap/issues/1772 + +impl Args for ListenCmd { + fn augment_args(app: App<'_>) -> App<'_> { + augment_args(app, true) + } + + fn augment_args_for_update(app: App<'_>) -> App<'_> { + augment_args(app, false) + } +} + +fn augment_args(app: App<'_>, required: bool) -> App<'_> { + app.arg( + Arg::new("chain_id") + .required(required) + .about("Identifier of the chain to listen for events from") + .validator(ChainId::from_str), + ) + .arg( + Arg::new("events") + .multiple_occurrences(true) + .short('e') + .long("event") + .value_name("EVENT") + .about( + "Add an event type to listen for, can be repeated.\n\ + Listen for all events by default (available: Tx, NewBlock)", + ) + .validator(EventFilter::from_str), + ) +} + +impl FromArgMatches for ListenCmd { + fn from_arg_matches(matches: &ArgMatches) -> Option { + let chain_id = parse_chain_id(matches).expect("the required argument should be present"); + let events = parse_event_filters(matches).unwrap_or_default(); + Some(ListenCmd { chain_id, events }) + } + + fn update_from_arg_matches(&mut self, matches: &ArgMatches) { + if let Some(chain_id) = parse_chain_id(matches) { + self.chain_id = chain_id; + } + if let Some(events) = parse_event_filters(matches) { + self.events = events; + } + } +} + +fn parse_chain_id(matches: &ArgMatches) -> Option { + let val = matches.value_of("chain_id")?; + Some(ChainId::from_str(val).unwrap()) +} + +fn parse_event_filters(matches: &ArgMatches) -> Option> { + let vals = matches.values_of("events")?; + Some(vals.map(|s| EventFilter::from_str(s).unwrap()).collect()) +} + impl Runnable for ListenCmd { fn run(&self) { self.cmd() @@ -98,15 +160,15 @@ pub fn listen( config: &ChainConfig, filters: &[EventFilter], ) -> Result<(), Box> { - info!( - "listening for events `{}` on '{}'...", - filters.iter().format(", "), - config.id - ); - let rt = Arc::new(TokioRuntime::new()?); let (event_monitor, rx) = subscribe(config, rt)?; + info!( + "[{}] listening for queries {}", + config.id, + event_monitor.queries().iter().format(", "), + ); + thread::spawn(|| event_monitor.run()); while let Ok(event_batch) = rx.recv() { diff --git a/relayer-cli/src/commands/misbehaviour.rs b/relayer-cli/src/commands/misbehaviour.rs index 43e4ca25c7..63ac0c5543 100644 --- a/relayer-cli/src/commands/misbehaviour.rs +++ b/relayer-cli/src/commands/misbehaviour.rs @@ -1,31 +1,29 @@ -use abscissa_core::{config, Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use ibc::core::ics02_client::events::UpdateClient; use ibc::core::ics02_client::height::Height; use ibc::core::ics24_host::identifier::{ChainId, ClientId}; use ibc::events::IbcEvent; use ibc_relayer::chain::handle::ChainHandle; +use ibc_relayer::config::Config; use ibc_relayer::foreign_client::{ForeignClient, MisbehaviourResults}; use std::ops::Deref; -use crate::application::CliApp; use crate::cli_utils::{spawn_chain_runtime, spawn_chain_runtime_generic}; use crate::conclude::Output; use crate::prelude::*; use ibc::core::ics02_client::client_state::ClientState; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct MisbehaviourCmd { - #[options( - free, - required, - help = "identifier of the chain where client updates are monitored for misbehaviour" + #[clap( + required = true, + about = "identifier of the chain where client updates are monitored for misbehaviour" )] chain_id: ChainId, - #[options( - free, - required, - help = "identifier of the client to be monitored for misbehaviour" + #[clap( + required = true, + about = "identifier of the client to be monitored for misbehaviour" )] client_id: ClientId, } @@ -45,7 +43,7 @@ impl Runnable for MisbehaviourCmd { pub fn monitor_misbehaviour( chain_id: &ChainId, client_id: &ClientId, - config: &config::Reader, + config: &Config, ) -> Result, Box> { let chain = spawn_chain_runtime(config, chain_id) .map_err(|e| format!("could not spawn the chain runtime for {}: {}", chain_id, e))?; @@ -95,7 +93,7 @@ pub fn monitor_misbehaviour( fn misbehaviour_handling( chain: Chain, - config: &config::Reader, + config: &Config, client_id: ClientId, update: Option, ) -> Result<(), Box> { diff --git a/relayer-cli/src/commands/query.rs b/relayer-cli/src/commands/query.rs index 4633a85aa5..eb37fb7e07 100644 --- a/relayer-cli/src/commands/query.rs +++ b/relayer-cli/src/commands/query.rs @@ -1,6 +1,6 @@ //! `query` subcommand -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use crate::commands::query::channel_ends::QueryChannelEndsCmd; use crate::commands::query::channels::QueryChannelsCmd; @@ -17,77 +17,77 @@ mod packet; mod tx; /// `query` subcommand -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum QueryCmd { /// The `query client` subcommand - #[options(help = "Query information about clients")] + #[clap(subcommand, about = "Query information about clients")] Client(QueryClientCmds), - #[options(help = "Query the identifiers of all clients on a chain")] + #[clap(about = "Query the identifiers of all clients on a chain")] Clients(clients::QueryAllClientsCmd), /// The `query connection` subcommand - #[options(help = "Query information about connections")] + #[clap(subcommand, about = "Query information about connections")] Connection(QueryConnectionCmds), /// The `query connections` subcommand - #[options(help = "Query the identifiers of all connections on a chain")] + #[clap(about = "Query the identifiers of all connections on a chain")] Connections(connections::QueryConnectionsCmd), /// The `query channel` subcommand - #[options(help = "Query information about channels")] + #[clap(subcommand, about = "Query information about channels")] Channel(QueryChannelCmds), /// The `query channels` subcommand - #[options(help = "Query the identifiers of all channels on a given chain")] + #[clap(about = "Query the identifiers of all channels on a given chain")] Channels(QueryChannelsCmd), /// The `query packet` subcommand - #[options(help = "Query information about packets")] + #[clap(subcommand, about = "Query information about packets")] Packet(QueryPacketCmds), /// The `query tx` subcommand - #[options(help = "Query information about transactions")] + #[clap(subcommand, about = "Query information about transactions")] Tx(tx::QueryTxCmd), } -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum QueryClientCmds { /// The `query client state` subcommand - #[options(help = "Query the client full state")] + #[clap(about = "Query the client full state")] State(client::QueryClientStateCmd), /// The `query client consensus` subcommand - #[options(help = "Query the client consensus state")] + #[clap(about = "Query the client consensus state")] Consensus(client::QueryClientConsensusCmd), /// The `query client header` subcommand - #[options(help = "Query for the header used in a client update at a certain height")] + #[clap(about = "Query for the header used in a client update at a certain height")] Header(client::QueryClientHeaderCmd), /// The `query client connections` subcommand - #[options(help = "Query the client connections")] + #[clap(about = "Query the client connections")] Connections(client::QueryClientConnectionsCmd), } -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum QueryConnectionCmds { /// The `query connection end` subcommand - #[options(help = "Query connection end")] + #[clap(about = "Query connection end")] End(connection::QueryConnectionEndCmd), /// The `query connection channels` subcommand - #[options(help = "Query connection channels")] + #[clap(about = "Query connection channels")] Channels(connection::QueryConnectionChannelsCmd), } -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum QueryChannelCmds { /// The `query channel end` subcommand - #[options(help = "Query channel end")] + #[clap(about = "Query channel end")] End(channel::QueryChannelEndCmd), /// The `query channel ends` subcommand - #[options(help = "Query channel ends and underlying connection and client objects")] + #[clap(about = "Query channel ends and underlying connection and client objects")] Ends(QueryChannelEndsCmd), } diff --git a/relayer-cli/src/commands/query/channel.rs b/relayer-cli/src/commands/query/channel.rs index 9253aea421..b488b2b139 100644 --- a/relayer-cli/src/commands/query/channel.rs +++ b/relayer-cli/src/commands/query/channel.rs @@ -1,6 +1,7 @@ use alloc::sync::Arc; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; +use clap::AppSettings::DisableHelpFlag; use tokio::runtime::Runtime as TokioRuntime; use ibc::core::ics24_host::identifier::ChainId; @@ -11,18 +12,20 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc::core::ics04_channel::channel::State; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] +#[clap(setting(DisableHelpFlag))] pub struct QueryChannelEndCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the port to query")] + #[clap(required = true, about = "identifier of the port to query")] port_id: PortId, - #[options(free, required, help = "identifier of the channel to query")] + #[clap(required = true, about = "identifier of the channel to query")] channel_id: ChannelId, - #[options(help = "height of the state to query", short = "h")] + // FIXME: rename the short option to avoid confusion with --help? + #[clap(short = 'h', long, about = "height of the state to query")] height: Option, } diff --git a/relayer-cli/src/commands/query/channel_ends.rs b/relayer-cli/src/commands/query/channel_ends.rs index 50efea3559..b4d1fd7538 100644 --- a/relayer-cli/src/commands/query/channel_ends.rs +++ b/relayer-cli/src/commands/query/channel_ends.rs @@ -1,4 +1,5 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; +use clap::AppSettings::DisableHelpFlag; use serde::{Deserialize, Serialize}; use ibc::core::ics02_client::client_state::{AnyClientState, ClientState}; @@ -13,23 +14,26 @@ use ibc_relayer::registry::Registry; use crate::conclude::Output; use crate::prelude::*; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] +#[clap(setting(DisableHelpFlag))] pub struct QueryChannelEndsCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the port to query")] + #[clap(required = true, about = "identifier of the port to query")] port_id: PortId, - #[options(free, required, help = "identifier of the channel to query")] + #[clap(required = true, about = "identifier of the channel to query")] channel_id: ChannelId, - #[options(help = "height of the state to query", short = "h")] + // FIXME: rename the short option to avoid confusion with --help? + #[clap(short = 'h', long, about = "height of the state to query")] height: Option, - #[options( - help = "enable verbose output, displaying all details of channels, connections & clients", - short = "v" + #[clap( + short = 'v', + long, + about = "enable verbose output, displaying all details of channels, connections & clients" )] verbose: bool, } diff --git a/relayer-cli/src/commands/query/channels.rs b/relayer-cli/src/commands/query/channels.rs index 0ba2d80b8b..a5c685183a 100644 --- a/relayer-cli/src/commands/query/channels.rs +++ b/relayer-cli/src/commands/query/channels.rs @@ -1,6 +1,6 @@ use core::fmt::{Debug, Error, Formatter}; -use abscissa_core::{Options, Runnable}; +use abscissa_core::{Clap, Runnable}; use serde::Serialize; use ibc::core::ics02_client::client_state::ClientState; @@ -15,17 +15,22 @@ use crate::commands::query::channel_ends::ChannelEnds; use crate::conclude::Output; use crate::prelude::*; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct QueryChannelsCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(help = "identifier of the channel's destination chain", short = "d")] + #[clap( + short = 'd', + long, + about = "identifier of the channel's destination chain" + )] destination_chain: Option, - #[options( - help = "enable verbose output, displaying all client and connection ids", - short = "v" + #[clap( + short = 'v', + long, + about = "enable verbose output, displaying all client and connection ids" )] verbose: bool, } diff --git a/relayer-cli/src/commands/query/client.rs b/relayer-cli/src/commands/query/client.rs index d9708e0235..8bff0e6473 100644 --- a/relayer-cli/src/commands/query/client.rs +++ b/relayer-cli/src/commands/query/client.rs @@ -1,6 +1,7 @@ use alloc::sync::Arc; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; +use clap::AppSettings::DisableHelpFlag; use tokio::runtime::Runtime as TokioRuntime; use tracing::debug; @@ -20,15 +21,17 @@ use crate::application::app_config; use crate::conclude::{exit_with_unrecoverable_error, Output}; /// Query client state command -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] +#[clap(setting(DisableHelpFlag))] pub struct QueryClientStateCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the client to query")] + #[clap(required = true, about = "identifier of the client to query")] client_id: ClientId, - #[options(help = "the chain height context for the query", short = "h")] + // FIXME: rename the short option to avoid confusion with --help? + #[clap(short = 'h', long, about = "the chain height context for the query")] height: Option, } @@ -62,23 +65,28 @@ impl Runnable for QueryClientStateCmd { } /// Query client consensus command -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct QueryClientConsensusCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the client to query")] + #[clap(required = true, about = "identifier of the client to query")] client_id: ClientId, - #[options(help = "height of the client's consensus state to query", short = "c")] + #[clap( + short = 'c', + long, + about = "height of the client's consensus state to query" + )] consensus_height: Option, - #[options(help = "show only consensus heights", short = "s")] + #[clap(short = 's', long, about = "show only consensus heights")] heights_only: bool, - #[options( - help = "the chain height context to be used, applicable only to a specific height", - short = "h" + #[clap( + short = 'h', + long, + about = "the chain height context to be used, applicable only to a specific height" )] height: Option, } @@ -152,18 +160,20 @@ impl Runnable for QueryClientConsensusCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] +#[clap(setting(DisableHelpFlag))] pub struct QueryClientHeaderCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the client to query")] + #[clap(required = true, about = "identifier of the client to query")] client_id: ClientId, - #[options(free, required, help = "height of header to query")] + #[clap(required = true, about = "height of header to query")] consensus_height: u64, - #[options(help = "the chain height context for the query", short = "h")] + // FIXME: rename the short option to avoid confusion with --help? + #[clap(short = 'h', long, about = "the chain height context for the query")] height: Option, } @@ -220,15 +230,19 @@ impl Runnable for QueryClientHeaderCmd { } /// Query client connections command -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct QueryClientConnectionsCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the client to query")] + #[clap(required = true, about = "identifier of the client to query")] client_id: ClientId, - #[options(help = "the chain height which this query should reflect", short = "h")] + #[clap( + short = 'h', + long, + about = "the chain height which this query should reflect" + )] height: Option, } diff --git a/relayer-cli/src/commands/query/clients.rs b/relayer-cli/src/commands/query/clients.rs index 68a103cf9b..55d3affde0 100644 --- a/relayer-cli/src/commands/query/clients.rs +++ b/relayer-cli/src/commands/query/clients.rs @@ -1,6 +1,6 @@ use alloc::sync::Arc; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use serde::Serialize; use tokio::runtime::Runtime as TokioRuntime; @@ -14,21 +14,20 @@ use crate::error::Error; use crate::prelude::*; /// Query clients command -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct QueryAllClientsCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options( - help = "filter for clients which target a specific chain id (implies '-o')", - meta = "ID" + #[clap( + short, + long, + about = "filter for clients which target a specific chain id (implies '-o')", + value_name = "ID" )] src_chain_id: Option, - #[options( - help = "omit printing the source chain for each client", - default = "false" - )] + #[clap(short, long, about = "omit printing the source chain for each client")] omit_chain_ids: bool, } diff --git a/relayer-cli/src/commands/query/connection.rs b/relayer-cli/src/commands/query/connection.rs index b2e6c52529..2ff5552f0a 100644 --- a/relayer-cli/src/commands/query/connection.rs +++ b/relayer-cli/src/commands/query/connection.rs @@ -1,6 +1,7 @@ use alloc::sync::Arc; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; +use clap::AppSettings::DisableHelpFlag; use tokio::runtime::Runtime as TokioRuntime; use ibc::core::{ @@ -15,15 +16,17 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::error::Error; use crate::prelude::*; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] +#[clap(setting(DisableHelpFlag))] pub struct QueryConnectionEndCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the connection to query")] + #[clap(required = true, about = "identifier of the connection to query")] connection_id: ConnectionId, - #[options(help = "height of the state to query", short = "h")] + // FIXME: rename the short option to avoid confusion with --help? + #[clap(short = 'h', long, about = "height of the state to query")] height: Option, } @@ -71,12 +74,12 @@ impl Runnable for QueryConnectionEndCmd { /// Command for querying the channel identifiers associated with a connection. /// Sample invocation: /// `cargo run --bin hermes -- query connection channels ibc-0 connection-0` -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct QueryConnectionChannelsCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the connection to query")] + #[clap(required = true, about = "identifier of the connection to query")] connection_id: ConnectionId, } diff --git a/relayer-cli/src/commands/query/connections.rs b/relayer-cli/src/commands/query/connections.rs index 6b68546c5f..d04d326a54 100644 --- a/relayer-cli/src/commands/query/connections.rs +++ b/relayer-cli/src/commands/query/connections.rs @@ -1,6 +1,6 @@ use alloc::sync::Arc; -use abscissa_core::{Options, Runnable}; +use abscissa_core::{Clap, Runnable}; use tokio::runtime::Runtime as TokioRuntime; use ibc::core::ics24_host::identifier::{ChainId, ConnectionId}; @@ -10,9 +10,9 @@ use ibc_relayer::chain::{ChainEndpoint, CosmosSdkChain}; use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct QueryConnectionsCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, } diff --git a/relayer-cli/src/commands/query/packet.rs b/relayer-cli/src/commands/query/packet.rs index 8330c012c7..760d7847a6 100644 --- a/relayer-cli/src/commands/query/packet.rs +++ b/relayer-cli/src/commands/query/packet.rs @@ -1,4 +1,4 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; mod ack; mod acks; @@ -7,29 +7,29 @@ mod commitments; mod unreceived_acks; mod unreceived_packets; -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum QueryPacketCmds { /// The `query packet commitments` subcommand - #[options(help = "Query packet commitments")] + #[clap(about = "Query packet commitments")] Commitments(commitments::QueryPacketCommitmentsCmd), /// The `query packet commitment` subcommand - #[options(help = "Query packet commitment")] + #[clap(about = "Query packet commitment")] Commitment(commitment::QueryPacketCommitmentCmd), /// The `query packet acks` subcommand - #[options(help = "Query packet acknowledgments")] + #[clap(about = "Query packet acknowledgments")] Acks(acks::QueryPacketAcknowledgementsCmd), /// The `query packet ack` subcommand - #[options(help = "Query packet acknowledgment")] + #[clap(about = "Query packet acknowledgment")] Ack(ack::QueryPacketAcknowledgmentCmd), /// The `query packet unreceived-packets` subcommand - #[options(help = "Query unreceived packets")] + #[clap(about = "Query unreceived packets")] UnreceivedPackets(unreceived_packets::QueryUnreceivedPacketsCmd), /// The `query packet unreceived-acks` subcommand - #[options(help = "Query unreceived acknowledgments")] + #[clap(about = "Query unreceived acknowledgments")] UnreceivedAcks(unreceived_acks::QueryUnreceivedAcknowledgementCmd), } diff --git a/relayer-cli/src/commands/query/packet/ack.rs b/relayer-cli/src/commands/query/packet/ack.rs index f76244a220..7d21fb6644 100644 --- a/relayer-cli/src/commands/query/packet/ack.rs +++ b/relayer-cli/src/commands/query/packet/ack.rs @@ -1,4 +1,5 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; +use clap::AppSettings::DisableHelpFlag; use subtle_encoding::{Encoding, Hex}; use ibc::core::ics04_channel::packet::{PacketMsgType, Sequence}; @@ -11,21 +12,23 @@ use crate::conclude::Output; use crate::error::Error; use crate::prelude::*; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] +#[clap(setting(DisableHelpFlag))] pub struct QueryPacketAcknowledgmentCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the port to query")] + #[clap(required = true, about = "identifier of the port to query")] port_id: PortId, - #[options(free, required, help = "identifier of the channel to query")] + #[clap(required = true, about = "identifier of the channel to query")] channel_id: ChannelId, - #[options(free, required, help = "sequence of packet to query")] + #[clap(required = true, about = "sequence of packet to query")] sequence: Sequence, - #[options(help = "height of the state to query", short = "h")] + // FIXME: rename the short option to avoid confusion with --help? + #[clap(short = 'h', long, about = "height of the state to query")] height: Option, } diff --git a/relayer-cli/src/commands/query/packet/acks.rs b/relayer-cli/src/commands/query/packet/acks.rs index 1daac41dd0..3d664f1653 100644 --- a/relayer-cli/src/commands/query/packet/acks.rs +++ b/relayer-cli/src/commands/query/packet/acks.rs @@ -1,4 +1,4 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use serde::Serialize; use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; @@ -17,15 +17,15 @@ struct PacketSeqs { seqs: Vec, } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct QueryPacketAcknowledgementsCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the port to query")] + #[clap(required = true, about = "identifier of the port to query")] port_id: PortId, - #[options(free, required, help = "identifier of the channel to query")] + #[clap(required = true, about = "identifier of the channel to query")] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/query/packet/commitment.rs b/relayer-cli/src/commands/query/packet/commitment.rs index 121e97e4ae..0a205f3599 100644 --- a/relayer-cli/src/commands/query/packet/commitment.rs +++ b/relayer-cli/src/commands/query/packet/commitment.rs @@ -1,4 +1,5 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; +use clap::AppSettings::DisableHelpFlag; use serde::Serialize; use subtle_encoding::{Encoding, Hex}; @@ -18,21 +19,23 @@ struct PacketSeqs { seqs: Vec, } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] +#[clap(setting(DisableHelpFlag))] pub struct QueryPacketCommitmentCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the port to query")] + #[clap(required = true, about = "identifier of the port to query")] port_id: PortId, - #[options(free, required, help = "identifier of the channel to query")] + #[clap(required = true, about = "identifier of the channel to query")] channel_id: ChannelId, - #[options(free, required, help = "sequence of packet to query")] + #[clap(required = true, about = "sequence of packet to query")] sequence: Sequence, - #[options(help = "height of the state to query", short = "h")] + // FIXME: rename the short option to avoid confusion with --help? + #[clap(short = 'h', long, about = "height of the state to query")] height: Option, } diff --git a/relayer-cli/src/commands/query/packet/commitments.rs b/relayer-cli/src/commands/query/packet/commitments.rs index 77a6925180..528e6043cb 100644 --- a/relayer-cli/src/commands/query/packet/commitments.rs +++ b/relayer-cli/src/commands/query/packet/commitments.rs @@ -1,4 +1,4 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use serde::Serialize; use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; @@ -16,15 +16,15 @@ struct PacketSeqs { seqs: Vec, } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct QueryPacketCommitmentsCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "identifier of the port to query")] + #[clap(required = true, about = "identifier of the port to query")] port_id: PortId, - #[options(free, required, help = "identifier of the channel to query")] + #[clap(required = true, about = "identifier of the channel to query")] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/query/packet/unreceived_acks.rs b/relayer-cli/src/commands/query/packet/unreceived_acks.rs index 37db000dd8..2f0a0fe8fb 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_acks.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_acks.rs @@ -1,4 +1,4 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; use ibc_relayer::chain::counterparty::unreceived_acknowledgements; @@ -13,19 +13,18 @@ use crate::prelude::*; /// 1. queries the chain to get its counterparty, channel and port identifiers (needed in 2) /// 2. queries the chain for all packet commitments/ sequences for a given port and channel /// 3. queries the counterparty chain for the unacknowledged sequences out of the list obtained in 2. -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct QueryUnreceivedAcknowledgementCmd { - #[options( - free, - required, - help = "identifier of the chain to query the unreceived acknowledgments" + #[clap( + required = true, + about = "identifier of the chain to query the unreceived acknowledgments" )] chain_id: ChainId, - #[options(free, required, help = "port identifier")] + #[clap(required = true, about = "port identifier")] port_id: PortId, - #[options(free, required, help = "channel identifier")] + #[clap(required = true, about = "channel identifier")] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/query/packet/unreceived_packets.rs b/relayer-cli/src/commands/query/packet/unreceived_packets.rs index 7e2d9d9ff3..47580c7823 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_packets.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_packets.rs @@ -1,4 +1,4 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use serde::Serialize; use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; @@ -21,19 +21,18 @@ struct PacketSeqs { /// 1. queries the chain to get its counterparty chain, channel and port identifiers (needed in 2) /// 2. queries the counterparty chain for all packet commitments/ sequences for a given port and channel /// 3. queries the chain for the unreceived sequences out of the list obtained in 2. -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct QueryUnreceivedPacketsCmd { - #[options( - free, - required, - help = "identifier of the chain for the unreceived sequences" + #[clap( + required = true, + about = "identifier of the chain for the unreceived sequences" )] chain_id: ChainId, - #[options(free, required, help = "port identifier")] + #[clap(required = true, about = "port identifier")] port_id: PortId, - #[options(free, required, help = "channel identifier")] + #[clap(required = true, about = "channel identifier")] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/query/tx.rs b/relayer-cli/src/commands/query/tx.rs index 1bd72845b9..99a5be85c4 100644 --- a/relayer-cli/src/commands/query/tx.rs +++ b/relayer-cli/src/commands/query/tx.rs @@ -1,13 +1,13 @@ //! `query tx` subcommand -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; mod events; /// `query tx` subcommand -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum QueryTxCmd { /// The `query tx events` subcommand - #[options(help = "Query the events emitted by transaction")] + #[clap(about = "Query the events emitted by transaction")] Events(events::QueryTxEventsCmd), } diff --git a/relayer-cli/src/commands/query/tx/events.rs b/relayer-cli/src/commands/query/tx/events.rs index 73e28259ca..b010a4dcc5 100644 --- a/relayer-cli/src/commands/query/tx/events.rs +++ b/relayer-cli/src/commands/query/tx/events.rs @@ -1,7 +1,7 @@ use alloc::sync::Arc; use core::str::FromStr; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use tokio::runtime::Runtime as TokioRuntime; use tracing::debug; @@ -19,12 +19,12 @@ use crate::error::Error; use crate::prelude::app_config; /// Query the events emitted by transaction -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct QueryTxEventsCmd { - #[options(free, required, help = "identifier of the chain to query")] + #[clap(required = true, about = "identifier of the chain to query")] chain_id: ChainId, - #[options(free, required, help = "transaction hash to query")] + #[clap(required = true, about = "transaction hash to query")] hash: String, } diff --git a/relayer-cli/src/commands/start.rs b/relayer-cli/src/commands/start.rs index 223e91f44f..75c7a1c521 100644 --- a/relayer-cli/src/commands/start.rs +++ b/relayer-cli/src/commands/start.rs @@ -3,7 +3,7 @@ use std::error::Error; use std::io; use std::sync::RwLock; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use crossbeam_channel::Sender; use ibc_relayer::chain::handle::{ChainHandle, ProdChainHandle}; @@ -16,7 +16,7 @@ use crate::conclude::json; use crate::conclude::Output; use crate::prelude::*; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct StartCmd {} impl Runnable for StartCmd { diff --git a/relayer-cli/src/commands/tx.rs b/relayer-cli/src/commands/tx.rs index d03cfd0bc7..99502153fe 100644 --- a/relayer-cli/src/commands/tx.rs +++ b/relayer-cli/src/commands/tx.rs @@ -1,5 +1,5 @@ //! `tx` subcommand -use abscissa_core::{config::Override, Command, Help, Options, Runnable}; +use abscissa_core::{config::Override, Clap, Command, Runnable}; use ibc_relayer::config::Config; use crate::commands::tx::client::{ @@ -15,93 +15,88 @@ mod upgrade; /// `tx` subcommand #[allow(clippy::large_enum_variant)] -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum TxCmd { - /// The `help` subcommand - #[options(help = "Get usage information")] - Help(Help), - /// The `tx raw` subcommand - #[options(help = "Raw commands for sending transactions to a configured chain.")] + #[clap( + subcommand, + about = "Raw commands for sending transactions to a configured chain." + )] Raw(TxRawCommands), } -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum TxRawCommands { - /// The `help` subcommand - #[options(help = "Get usage information")] - Help(Help), - /// The `tx raw create-client` subcommand submits a MsgCreateClient in a transaction to a chain - #[options(help = "Create a client for source chain on destination chain")] + #[clap(about = "Create a client for source chain on destination chain")] CreateClient(TxCreateClientCmd), /// The `tx raw update-client` subcommand submits a MsgUpdateClient in a transaction to a chain - #[options(help = "Update the specified client on destination chain")] + #[clap(about = "Update the specified client on destination chain")] UpdateClient(TxUpdateClientCmd), /// The `tx raw upgrade-client` subcommand. Submits a MsgUpgradeClient in a transaction to a chain. - #[options(help = "Upgrade the specified client on destination chain")] + #[clap(about = "Upgrade the specified client on destination chain")] UpgradeClient(TxUpgradeClientCmd), /// The `tx raw upgrade-clients` subcommand. Submits a MsgUpgradeClient in a transaction to multiple chains. - #[options(help = "Upgrade all IBC clients that target a specific chain")] + #[clap(about = "Upgrade all IBC clients that target a specific chain")] UpgradeClients(TxUpgradeClientsCmd), /// The `tx raw conn-init` subcommand - #[options(help = "Initialize a connection (ConnectionOpenInit)")] + #[clap(about = "Initialize a connection (ConnectionOpenInit)")] ConnInit(connection::TxRawConnInitCmd), /// The `tx raw conn-try` subcommand - #[options(help = "Relay the connection attempt (ConnectionOpenTry)")] + #[clap(about = "Relay the connection attempt (ConnectionOpenTry)")] ConnTry(connection::TxRawConnTryCmd), /// The `tx raw conn-ack` subcommand - #[options(help = "Relay acknowledgment of a connection attempt (ConnectionOpenAck)")] + #[clap(about = "Relay acknowledgment of a connection attempt (ConnectionOpenAck)")] ConnAck(connection::TxRawConnAckCmd), /// The `tx raw conn-confirm` subcommand - #[options(help = "Confirm opening of a connection (ConnectionOpenConfirm)")] + #[clap(about = "Confirm opening of a connection (ConnectionOpenConfirm)")] ConnConfirm(connection::TxRawConnConfirmCmd), /// The `tx raw chan-open-init` subcommand - #[options(help = "Initialize a channel (ChannelOpenInit)")] + #[clap(about = "Initialize a channel (ChannelOpenInit)")] ChanOpenInit(channel::TxRawChanOpenInitCmd), /// The `tx raw chan-try` subcommand - #[options(help = "Relay the channel attempt (ChannelOpenTry)")] + #[clap(about = "Relay the channel attempt (ChannelOpenTry)")] ChanOpenTry(channel::TxRawChanOpenTryCmd), /// The `tx raw chan-open-ack` subcommand - #[options(help = "Relay acknowledgment of a channel attempt (ChannelOpenAck)")] + #[clap(about = "Relay acknowledgment of a channel attempt (ChannelOpenAck)")] ChanOpenAck(channel::TxRawChanOpenAckCmd), /// The `tx raw chan-open-confirm` subcommand - #[options(help = "Confirm opening of a channel (ChannelOpenConfirm)")] + #[clap(about = "Confirm opening of a channel (ChannelOpenConfirm)")] ChanOpenConfirm(channel::TxRawChanOpenConfirmCmd), /// The `tx raw chan-close-init` subcommand - #[options(help = "Initiate the closing of a channel (ChannelCloseInit)")] + #[clap(about = "Initiate the closing of a channel (ChannelCloseInit)")] ChanCloseInit(channel::TxRawChanCloseInitCmd), /// The `tx raw chan-close-confirm` subcommand - #[options(help = "Confirm the closing of a channel (ChannelCloseConfirm)")] + #[clap(about = "Confirm the closing of a channel (ChannelCloseConfirm)")] ChanCloseConfirm(channel::TxRawChanCloseConfirmCmd), /// The `tx raw packet-send` subcommand - #[options(help = "Send a fungible token transfer test transaction (ICS20 MsgTransfer)")] + #[clap(about = "Send a fungible token transfer test transaction (ICS20 MsgTransfer)")] FtTransfer(transfer::TxIcs20MsgTransferCmd), /// The `tx raw packet-recv` subcommand - #[options(help = "Relay receive or timeout packets")] + #[clap(about = "Relay receive or timeout packets")] PacketRecv(packet::TxRawPacketRecvCmd), /// The `tx raw packet-ack` subcommand - #[options(help = "Relay acknowledgment packets")] + #[clap(about = "Relay acknowledgment packets")] PacketAck(packet::TxRawPacketAckCmd), /// The `tx raw upgrade-chain` subcommand - #[options(help = "Send an IBC upgrade plan")] + #[clap(about = "Send an IBC upgrade plan")] UpgradeChain(upgrade::TxIbcUpgradeChainCmd), } @@ -109,7 +104,6 @@ impl Override for TxCmd { fn override_config(&self, config: Config) -> Result { match self { Self::Raw(cmd) => cmd.override_config(config), - _ => Ok(config), } } } diff --git a/relayer-cli/src/commands/tx/channel.rs b/relayer-cli/src/commands/tx/channel.rs index 149d70f145..69e840f708 100644 --- a/relayer-cli/src/commands/tx/channel.rs +++ b/relayer-cli/src/commands/tx/channel.rs @@ -1,4 +1,4 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use ibc::core::ics03_connection::connection::ConnectionEnd; use ibc::core::ics04_channel::channel::Order; @@ -45,24 +45,29 @@ macro_rules! tx_chan_cmd { }; } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawChanOpenInitCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the destination connection")] + #[clap(required = true, about = "identifier of the destination connection")] dst_conn_id: ConnectionId, - #[options(free, required, help = "identifier of the destination port")] + #[clap(required = true, about = "identifier of the destination port")] dst_port_id: PortId, - #[options(free, required, help = "identifier of the source port")] + #[clap(required = true, about = "identifier of the source port")] src_port_id: PortId, - #[options(help = "the channel ordering, valid options 'unordered' (default) and 'ordered'")] + #[clap( + short, + long, + default_value_t, + about = "the channel ordering, valid options 'unordered' (default) and 'ordered'" + )] order: Order, } @@ -117,35 +122,37 @@ impl Runnable for TxRawChanOpenInitCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawChanOpenTryCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the destination connection")] + #[clap(required = true, about = "identifier of the destination connection")] dst_conn_id: ConnectionId, - #[options(free, required, help = "identifier of the destination port")] + #[clap(required = true, about = "identifier of the destination port")] dst_port_id: PortId, - #[options(free, required, help = "identifier of the source port")] + #[clap(required = true, about = "identifier of the source port")] src_port_id: PortId, - #[options( - required, - help = "identifier of the source channel (required)", - short = "s", - meta = "ID" + #[clap( + short = 's', + long, + required = true, + about = "identifier of the source channel (required)", + value_name = "ID" )] src_chan_id: ChannelId, - #[options( - help = "identifier of the destination channel (optional)", - short = "d", - meta = "ID" + #[clap( + short = 'd', + long, + about = "identifier of the destination channel (optional)", + value_name = "ID" )] dst_chan_id: Option, } @@ -228,36 +235,38 @@ impl Runnable for TxRawChanOpenTryCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawChanOpenAckCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the destination connection")] + #[clap(required = true, about = "identifier of the destination connection")] dst_conn_id: ConnectionId, - #[options(free, required, help = "identifier of the destination port")] + #[clap(required = true, about = "identifier of the destination port")] dst_port_id: PortId, - #[options(free, required, help = "identifier of the source port")] + #[clap(required = true, about = "identifier of the source port")] src_port_id: PortId, - #[options( - required, - help = "identifier of the destination channel (required)", - short = "d", - meta = "ID" + #[clap( + short = 'd', + long, + required = true, + about = "identifier of the destination channel (required)", + value_name = "ID" )] dst_chan_id: ChannelId, - #[options( - required, - help = "identifier of the source channel (required)", - short = "s", - meta = "ID" + #[clap( + short = 's', + long, + required = true, + about = "identifier of the source channel (required)", + value_name = "ID" )] src_chan_id: ChannelId, } @@ -293,36 +302,38 @@ impl Runnable for TxRawChanOpenAckCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawChanOpenConfirmCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the destination connection")] + #[clap(required = true, about = "identifier of the destination connection")] dst_conn_id: ConnectionId, - #[options(free, required, help = "identifier of the destination port")] + #[clap(required = true, about = "identifier of the destination port")] dst_port_id: PortId, - #[options(free, required, help = "identifier of the source port")] + #[clap(required = true, about = "identifier of the source port")] src_port_id: PortId, - #[options( - required, - help = "identifier of the destination channel (required)", - short = "d", - meta = "ID" + #[clap( + short = 'd', + long, + required = true, + about = "identifier of the destination channel (required)", + value_name = "ID" )] dst_chan_id: ChannelId, - #[options( - required, - help = "identifier of the source channel (required)", - short = "s", - meta = "ID" + #[clap( + short = 's', + long, + required = true, + about = "identifier of the source channel (required)", + value_name = "ID" )] src_chan_id: ChannelId, } @@ -358,36 +369,38 @@ impl Runnable for TxRawChanOpenConfirmCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawChanCloseInitCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the destination connection")] + #[clap(required = true, about = "identifier of the destination connection")] dst_conn_id: ConnectionId, - #[options(free, required, help = "identifier of the destination port")] + #[clap(required = true, about = "identifier of the destination port")] dst_port_id: PortId, - #[options(free, required, help = "identifier of the source port")] + #[clap(required = true, about = "identifier of the source port")] src_port_id: PortId, - #[options( - required, - help = "identifier of the destination channel (required)", - short = "d", - meta = "ID" + #[clap( + short = 'd', + long, + required = true, + about = "identifier of the destination channel (required)", + value_name = "ID" )] dst_chan_id: ChannelId, - #[options( - required, - help = "identifier of the source channel (required)", - short = "s", - meta = "ID" + #[clap( + short = 's', + long, + required = true, + about = "identifier of the source channel (required)", + value_name = "ID" )] src_chan_id: ChannelId, } @@ -423,36 +436,38 @@ impl Runnable for TxRawChanCloseInitCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawChanCloseConfirmCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the destination connection")] + #[clap(required = true, about = "identifier of the destination connection")] dst_conn_id: ConnectionId, - #[options(free, required, help = "identifier of the destination port")] + #[clap(required = true, about = "identifier of the destination port")] dst_port_id: PortId, - #[options(free, required, help = "identifier of the source port")] + #[clap(required = true, about = "identifier of the source port")] src_port_id: PortId, - #[options( - required, - help = "identifier of the destination channel (required)", - short = "d", - meta = "ID" + #[clap( + short = 'd', + long, + required = true, + about = "identifier of the destination channel (required)", + value_name = "ID" )] dst_chan_id: ChannelId, - #[options( - required, - help = "identifier of the source channel (required)", - short = "s", - meta = "ID" + #[clap( + short = 's', + long, + required = true, + about = "identifier of the source channel (required)", + value_name = "ID" )] src_chan_id: ChannelId, } diff --git a/relayer-cli/src/commands/tx/client.rs b/relayer-cli/src/commands/tx/client.rs index a86a16ad91..d682ed92ab 100644 --- a/relayer-cli/src/commands/tx/client.rs +++ b/relayer-cli/src/commands/tx/client.rs @@ -1,25 +1,27 @@ use core::fmt; -use abscissa_core::{config, Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; +use clap::AppSettings::DisableHelpFlag; use ibc::core::ics02_client::client_state::ClientState; use ibc::core::ics24_host::identifier::{ChainId, ClientId}; use ibc::events::IbcEvent; use ibc_proto::ibc::core::client::v1::QueryClientStatesRequest; use ibc_relayer::chain::handle::ChainHandle; +use ibc_relayer::config::Config; use ibc_relayer::foreign_client::ForeignClient; -use crate::application::{app_config, CliApp}; +use crate::application::app_config; use crate::cli_utils::{spawn_chain_runtime, spawn_chain_runtime_generic, ChainHandlePair}; use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::error::Error; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxCreateClientCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, } @@ -52,22 +54,23 @@ impl Runnable for TxCreateClientCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] +#[clap(setting(DisableHelpFlag))] pub struct TxUpdateClientCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options( - free, - required, - help = "identifier of the client to be updated on destination chain" + #[clap( + required = true, + about = "identifier of the client to be updated on destination chain" )] dst_client_id: ClientId, - #[options(help = "the target height of the client update", short = "h")] + // FIXME: rename the short option to avoid confusion with --help? + #[clap(short = 'h', long, about = "the target height of the client update")] target_height: Option, - #[options(help = "the trusted height of the client update", short = "t")] + #[clap(short = 't', long, about = "the trusted height of the client update")] trusted_height: Option, } @@ -121,12 +124,15 @@ impl Runnable for TxUpdateClientCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxUpgradeClientCmd { - #[options(free, required, help = "identifier of the chain that hosts the client")] + #[clap( + required = true, + about = "identifier of the chain that hosts the client" + )] chain_id: ChainId, - #[options(free, required, help = "identifier of the client to be upgraded")] + #[clap(required = true, about = "identifier of the client to be upgraded")] client_id: ClientId, } @@ -168,12 +174,11 @@ impl Runnable for TxUpgradeClientCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxUpgradeClientsCmd { - #[options( - free, - required, - help = "identifier of the chain that underwent an upgrade; all clients targeting this chain will be upgraded" + #[clap( + required = true, + about = "identifier of the chain that underwent an upgrade; all clients targeting this chain will be upgraded" )] src_chain_id: ChainId, } @@ -206,7 +211,7 @@ impl Runnable for TxUpgradeClientsCmd { impl TxUpgradeClientsCmd { fn upgrade_clients_for_chain( &self, - config: &config::Reader, + config: &Config, src_chain: Chain, dst_chain_id: &ChainId, ) -> UpgradeClientsForChainResult { diff --git a/relayer-cli/src/commands/tx/connection.rs b/relayer-cli/src/commands/tx/connection.rs index cdf25de5da..4222ff1858 100644 --- a/relayer-cli/src/commands/tx/connection.rs +++ b/relayer-cli/src/commands/tx/connection.rs @@ -1,4 +1,4 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use ibc::core::ics24_host::identifier::{ChainId, ClientId, ConnectionId}; use ibc::events::IbcEvent; @@ -33,18 +33,18 @@ macro_rules! conn_open_cmd { }; } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawConnInitCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the destination client")] + #[clap(required = true, about = "identifier of the destination client")] dst_client_id: ClientId, - #[options(free, required, help = "identifier of the source client")] + #[clap(required = true, about = "identifier of the source client")] src_client_id: ClientId, } @@ -65,32 +65,34 @@ impl Runnable for TxRawConnInitCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawConnTryCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the destination client")] + #[clap(required = true, about = "identifier of the destination client")] dst_client_id: ClientId, - #[options(free, required, help = "identifier of the source client")] + #[clap(required = true, about = "identifier of the source client")] src_client_id: ClientId, - #[options( - required, - help = "identifier of the source connection (required)", - short = "s", - meta = "ID" + #[clap( + short = 's', + long, + required = true, + about = "identifier of the source connection (required)", + value_name = "ID" )] src_conn_id: ConnectionId, - #[options( - help = "identifier of the destination connection (optional)", - short = "d", - meta = "ID" + #[clap( + short = 'd', + long, + about = "identifier of the destination connection (optional)", + value_name = "ID" )] dst_conn_id: Option, } @@ -120,33 +122,35 @@ impl Runnable for TxRawConnTryCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawConnAckCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the destination client")] + #[clap(required = true, about = "identifier of the destination client")] dst_client_id: ClientId, - #[options(free, required, help = "identifier of the source client")] + #[clap(required = true, about = "identifier of the source client")] src_client_id: ClientId, - #[options( - required, - help = "identifier of the destination connection (required)", - short = "d", - meta = "ID" + #[clap( + short = 'd', + long, + required = true, + about = "identifier of the destination connection (required)", + value_name = "ID" )] dst_conn_id: ConnectionId, - #[options( - required, - help = "identifier of the source connection (required)", - short = "s", - meta = "ID" + #[clap( + short = 's', + long, + required = true, + about = "identifier of the source connection (required)", + value_name = "ID" )] src_conn_id: ConnectionId, } @@ -176,33 +180,35 @@ impl Runnable for TxRawConnAckCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawConnConfirmCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the destination client")] + #[clap(required = true, about = "identifier of the destination client")] dst_client_id: ClientId, - #[options(free, required, help = "identifier of the source client")] + #[clap(required = true, about = "identifier of the source client")] src_client_id: ClientId, - #[options( - required, - help = "identifier of the destination connection (required)", - short = "d", - meta = "ID" + #[clap( + short = 'd', + long, + required = true, + about = "identifier of the destination connection (required)", + value_name = "ID" )] dst_conn_id: ConnectionId, - #[options( - required, - help = "identifier of the source connection (required)", - short = "s", - meta = "ID" + #[clap( + short = 's', + long, + required = true, + about = "identifier of the source connection (required)", + value_name = "ID" )] src_conn_id: ConnectionId, } diff --git a/relayer-cli/src/commands/tx/packet.rs b/relayer-cli/src/commands/tx/packet.rs index e68ce8a2d6..f206321c00 100644 --- a/relayer-cli/src/commands/tx/packet.rs +++ b/relayer-cli/src/commands/tx/packet.rs @@ -1,4 +1,4 @@ -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; use ibc::events::IbcEvent; @@ -9,18 +9,18 @@ use crate::conclude::Output; use crate::error::Error; use crate::prelude::*; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawPacketRecvCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the source port")] + #[clap(required = true, about = "identifier of the source port")] src_port_id: PortId, - #[options(free, required, help = "identifier of the source channel")] + #[clap(required = true, about = "identifier of the source channel")] src_channel_id: ChannelId, } @@ -53,18 +53,18 @@ impl Runnable for TxRawPacketRecvCmd { } } -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxRawPacketAckCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the source port")] + #[clap(required = true, about = "identifier of the source port")] src_port_id: PortId, - #[options(free, required, help = "identifier of the source channel")] + #[clap(required = true, about = "identifier of the source channel")] src_channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/tx/transfer.rs b/relayer-cli/src/commands/tx/transfer.rs index 64a5cb8c91..8e7ec5de91 100644 --- a/relayer-cli/src/commands/tx/transfer.rs +++ b/relayer-cli/src/commands/tx/transfer.rs @@ -1,4 +1,4 @@ -use abscissa_core::{config::Override, Command, FrameworkErrorKind, Options, Runnable}; +use abscissa_core::{config::Override, Clap, Command, FrameworkErrorKind, Runnable}; use ibc::{ core::{ @@ -20,52 +20,64 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::error::Error; use crate::prelude::*; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxIcs20MsgTransferCmd { - #[options(free, required, help = "identifier of the destination chain")] + #[clap(required = true, about = "identifier of the destination chain")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options(free, required, help = "identifier of the source port")] + #[clap(required = true, about = "identifier of the source port")] src_port_id: PortId, - #[options(free, required, help = "identifier of the source channel")] + #[clap(required = true, about = "identifier of the source channel")] src_channel_id: ChannelId, - #[options( - free, - required, - help = "amount of coins (samoleans, by default) to send (e.g. `100000`)" + #[clap( + required = true, + about = "amount of coins (samoleans, by default) to send (e.g. `100000`)" )] amount: Amount, - #[options(help = "timeout in number of blocks since current", short = "o")] + #[clap( + short = 'o', + long, + default_value = "0", + about = "timeout in number of blocks since current" + )] timeout_height_offset: u64, - #[options(help = "timeout in seconds since current", short = "t")] + #[clap( + short = 't', + long, + default_value = "0", + about = "timeout in seconds since current" + )] timeout_seconds: u64, - #[options( - help = "receiving account address on the destination chain", - short = "r" + #[clap( + short = 'r', + long, + about = "receiving account address on the destination chain" )] receiver: Option, - #[options( - help = "denomination of the coins to send", - short = "d", - default = "samoleans" + #[clap( + short = 'd', + long, + about = "denomination of the coins to send", + default_value = "samoleans" )] denom: String, - #[options(help = "number of messages to send", short = "n")] + #[clap(short = 'n', long, about = "number of messages to send")] number_msgs: Option, - #[options( - help = "use the given signing key (default: `key_name` config)", - short = "k" + #[clap( + short = 'k', + long, + about = "use the given signing key (default: `key_name` config)" )] key: Option, } @@ -115,7 +127,9 @@ impl TxIcs20MsgTransferCmd { if self.timeout_height_offset == 0 && self.timeout_seconds == 0 { return Err( - "packet timeout height and packet timeout timestamp cannot both be 0".into(), + "packet timeout height and packet timeout timestamp cannot both be 0, \ + please specify either --timeout-height-offset or --timeout-seconds" + .into(), ); } diff --git a/relayer-cli/src/commands/tx/upgrade.rs b/relayer-cli/src/commands/tx/upgrade.rs index 904462af6a..fdafa087a3 100644 --- a/relayer-cli/src/commands/tx/upgrade.rs +++ b/relayer-cli/src/commands/tx/upgrade.rs @@ -1,7 +1,7 @@ use alloc::sync::Arc; use core::time::Duration; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use tokio::runtime::Runtime as TokioRuntime; use ibc::core::ics24_host::identifier::{ChainId, ClientId}; @@ -16,55 +16,57 @@ use crate::conclude::Output; use crate::error::Error; use crate::prelude::*; -#[derive(Clone, Command, Debug, Options)] +#[derive(Clone, Command, Debug, Clap)] pub struct TxIbcUpgradeChainCmd { - #[options(free, required, help = "identifier of the chain to upgrade")] + #[clap(required = true, about = "identifier of the chain to upgrade")] dst_chain_id: ChainId, - #[options(free, required, help = "identifier of the source chain")] + #[clap(required = true, about = "identifier of the source chain")] src_chain_id: ChainId, - #[options( - free, - required, - help = "identifier of the client on source chain from which the plan is created" + #[clap( + required = true, + about = "identifier of the client on source chain from which the plan is created" )] src_client_id: ClientId, - #[options(free, required, help = "amount of stake")] + #[clap(required = true, about = "amount of stake")] amount: u64, - #[options( - free, - required, - help = "upgrade height offset in number of blocks since current" + #[clap( + required = true, + about = "upgrade height offset in number of blocks since current" )] height_offset: u64, - #[options( - short = "c", - meta = "CHAIN-ID", - help = "new chain identifier to assign to the upgrading chain (optional)" + #[clap( + short = 'c', + long, + value_name = "CHAIN-ID", + about = "new chain identifier to assign to the upgrading chain (optional)" )] new_chain_id: Option, - #[options( - short = "u", - meta = "PERIOD", - help = "new unbonding period to assign to the upgrading chain, in seconds (optional)" + #[clap( + short = 'u', + long, + value_name = "PERIOD", + about = "new unbonding period to assign to the upgrading chain, in seconds (optional)" )] new_unbonding: Option, - #[options( - short = "n", - meta = "NAME", - help = "a string to name the upgrade proposal plan (default: 'plan')" + #[clap( + short = 'n', + long, + value_name = "NAME", + about = "a string to name the upgrade proposal plan (default: 'plan')" )] upgrade_name: Option, - #[options( - help = "use legacy upgrade proposal constructs (for chains built with Cosmos SDK < v0.43.0)", - short = "l" + #[clap( + short = 'l', + long, + about = "use legacy upgrade proposal constructs (for chains built with Cosmos SDK < v0.43.0)" )] legacy: bool, } diff --git a/relayer-cli/src/commands/update.rs b/relayer-cli/src/commands/update.rs index 46d09b55d6..c46d1edc7b 100644 --- a/relayer-cli/src/commands/update.rs +++ b/relayer-cli/src/commands/update.rs @@ -1,16 +1,12 @@ //! `update` subcommand -use abscissa_core::{Command, Help, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use crate::commands::tx::client::TxUpdateClientCmd; -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum UpdateCmds { - /// Generic `help` - #[options(help = "Get usage information")] - Help(Help), - /// Subcommand for updating a `client` - #[options(help = "Update an IBC client")] + #[clap(about = "Update an IBC client")] Client(TxUpdateClientCmd), } diff --git a/relayer-cli/src/commands/upgrade.rs b/relayer-cli/src/commands/upgrade.rs index a708065a4d..44f5daa9e8 100644 --- a/relayer-cli/src/commands/upgrade.rs +++ b/relayer-cli/src/commands/upgrade.rs @@ -1,20 +1,16 @@ //! `upgrade` subcommand -use abscissa_core::{Command, Help, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; use crate::commands::tx::client::{TxUpgradeClientCmd, TxUpgradeClientsCmd}; -#[derive(Command, Debug, Options, Runnable)] +#[derive(Command, Debug, Clap, Runnable)] pub enum UpgradeCmds { - /// Generic `help` - #[options(help = "Get usage information")] - Help(Help), - /// Subcommand for upgrading a `client` - #[options(help = "Upgrade an IBC client")] + #[clap(about = "Upgrade an IBC client")] Client(TxUpgradeClientCmd), /// Subcommand for upgrading all `client`s that target specified chain - #[options(help = "Upgrade all IBC clients that target a specific chain")] + #[clap(about = "Upgrade all IBC clients that target a specific chain")] Clients(TxUpgradeClientsCmd), } diff --git a/relayer-cli/src/commands/version.rs b/relayer-cli/src/commands/version.rs index e4fc0e328b..09acbe9d22 100644 --- a/relayer-cli/src/commands/version.rs +++ b/relayer-cli/src/commands/version.rs @@ -1,15 +1,19 @@ //! `version` subcommand use super::CliCmd; -use abscissa_core::{Command, Options, Runnable}; +use abscissa_core::{Clap, Command, Runnable}; /// `version` subcommand -#[derive(Command, Debug, Default, Options)] +/// +/// This subcommand is implemented for backward compatibility reasons. +/// Its behavior should be the same as that of the `--version` flag which +/// is handled internally by clap. +#[derive(Command, Debug, Default, Clap)] pub struct VersionCmd {} impl Runnable for VersionCmd { /// Print version message fn run(&self) { - println!("{} {}", CliCmd::name(), CliCmd::version()); + println!("{} {}", CliCmd::name(), clap::crate_version!()); } } diff --git a/relayer-cli/src/entry.rs b/relayer-cli/src/entry.rs index c7ddc1951f..5ce19e2a23 100644 --- a/relayer-cli/src/entry.rs +++ b/relayer-cli/src/entry.rs @@ -1,99 +1,52 @@ use std::path::PathBuf; +use std::process; -use abscissa_core::command::Usage; -use abscissa_core::{Command, Config, Configurable, FrameworkError, Options, Runnable}; +use abscissa_core::{Clap, Command, Configurable, FrameworkError, Runnable}; +use clap::IntoApp; +use ibc_relayer::config::Config; -/// Custom entry point for Hermes. -/// -/// Replaces `abscissa_core::EntryPoint` with custom-made flag (for JSON output). -#[derive(Debug, Options)] -pub struct EntryPoint -where - Cmd: Command + Runnable, -{ +use crate::commands::CliCmd; + +/// Entry point for Hermes CLI. +#[derive(Command, Debug, Clap)] +#[clap(author, about, version)] +pub struct EntryPoint { /// Path to the configuration file - #[options(short = "c", help = "path to configuration file")] + #[clap(short = 'c', long, about = "path to configuration file")] pub config: Option, /// Toggle JSON output mode one verbosity setting - #[options(short = "j", help = "enable JSON output")] + #[clap(short = 'j', long, about = "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, + #[clap(subcommand)] + pub command: Option, } -impl EntryPoint -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 Runnable for EntryPoint -where - Cmd: Command + Runnable, -{ +impl Runnable for EntryPoint { fn run(&self) { - self.command().run() - } -} - -impl Command for EntryPoint -where - Cmd: Command + Runnable, -{ - /// Name of this program as a string - fn name() -> &'static str { - "hermes" - } - - /// Description of this program. - /// Used whenever a command's usage is printed - /// (i.e., after the user invoked a command wrongly). - /// - /// Note: - /// Any new line or extra white spaces in the returned &str - /// here will be trimmed (see `Usage`), so the returned - /// &str should be a concise one-liner help message. - fn description() -> &'static str { - r#" - For help, run `hermes [] help `, for example: `hermes help create client` - "# - } - - /// 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 { - Cmd::subcommand_usage(command) + match &self.command { + Some(cmd) => cmd.run(), + None => { + EntryPoint::into_app().print_help().unwrap(); + process::exit(0); + } + } } } -impl Configurable for EntryPoint -where - Cmd: Command + Configurable + Runnable, - Cfg: Config, -{ +impl Configurable for EntryPoint { /// Path to the command's configuration file fn config_path(&self) -> Option { + // Skip config processing for the legacy `version` subcommand + if matches!(&self.command, Some(CliCmd::Version(_))) { + return None; + } + match &self.config { // Use explicit `-c`/`--config` argument if passed Some(cfg) => Some(cfg.clone()), @@ -105,7 +58,7 @@ where /// 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 { + fn process_config(&self, config: Config) -> Result { match &self.command { Some(cmd) => cmd.process_config(config), None => Ok(config), diff --git a/relayer-cli/src/prelude.rs b/relayer-cli/src/prelude.rs index b22d0225de..bc45c61b63 100644 --- a/relayer-cli/src/prelude.rs +++ b/relayer-cli/src/prelude.rs @@ -6,4 +6,4 @@ pub use abscissa_core::prelude::*; /// Application state accessors -pub use crate::application::{app_config, app_reader, app_writer}; +pub use crate::application::{app_config, app_reader}; diff --git a/relayer/src/event/monitor.rs b/relayer/src/event/monitor.rs index d3b2e5a744..1392bc5566 100644 --- a/relayer/src/event/monitor.rs +++ b/relayer/src/event/monitor.rs @@ -167,6 +167,11 @@ impl EventMonitor { Ok((monitor, rx_batch, tx_cmd)) } + /// The list of [`Query`] that this event monitor is subscribing for. + pub fn queries(&self) -> &[Query] { + &self.event_queries + } + /// Clear the current subscriptions, and subscribe again to all queries. pub fn subscribe(&mut self) -> Result<()> { let mut subscriptions = vec![];