Skip to content

Commit

Permalink
Standartize Opts processing
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jun 21, 2022
1 parent 6474457 commit cfe49d3
Show file tree
Hide file tree
Showing 30 changed files with 356 additions and 280 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ lnpbp = "0.7.0"
lnp-core = { version = "0.8.0-alpha.1", git = "https://github.com/LNP-WG/lnp-core" }
lnp_rpc = { version = "0.8.0-alpha.1", path = "./rpc" }
internet2 = { version = "0.8.0-beta.1", features = ["keygen"] }
microservices = { version = "0.8.0-rc.6", default-features = false, features = ["node", "peer"], git = "https://github.com/Internet2-WG/rust-microservices" }
microservices = { version = "0.8.0-rc.8", default-features = false, features = ["node", "peer"], git = "https://github.com/Internet2-WG/rust-microservices" }
# Bitcoin
bitcoin = { version = "0.28.1", features = ["rand"] }
miniscript = "7.0.0"
Expand Down Expand Up @@ -83,7 +83,7 @@ lightning-invoice = "0.14.0"
lnp-core = { version = "0.8.0-alpha.1", git = "https://github.com/LNP-WG/lnp-core" }
lnp_rpc = { version = "0.8.0-alpha.1", path = "./rpc" }
internet2 = "0.8.0-beta.1"
microservices = { version = "0.8.0-rc.6", default-features = false, features = ["peer"], git = "https://github.com/Internet2-WG/rust-microservices" }
microservices = { version = "0.8.0-rc.8", default-features = false, features = ["peer"], git = "https://github.com/Internet2-WG/rust-microservices" }
clap = { version = "~3.1.18", features = ["env"] }
clap_complete = "~3.1.4"
log = { version = "0.4", features = ["max_level_trace", "release_max_level_debug"] }
Expand Down
8 changes: 4 additions & 4 deletions cli/src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::str::FromStr;
use internet2::addr::{PartialNodeAddr, ServiceAddr};
use lightning_invoice::Invoice;
use lnp::p2p::bolt::{ChannelId, ChannelType};
use lnp_rpc::LNP_NODE_RPC_SOCKET;
use lnp_rpc::LNP_NODE_RPC_ENDPOINT;

/// Command-line tool for working with LNP node
#[derive(Parser, Clone, PartialEq, Eq, Debug)]
Expand All @@ -31,11 +31,11 @@ pub struct Opts {
///
/// Defaults to `127.0.0.1:62962`.
#[clap(
short,
short = 'R',
long,
global = true,
default_value = LNP_NODE_RPC_SOCKET,
env = "LNP_NODE_RPC_SOCKET"
default_value = LNP_NODE_RPC_ENDPOINT,
env = "LNP_NODE_RPC_ENDPOINT"
)]
pub connect: ServiceAddr,

Expand Down
2 changes: 1 addition & 1 deletion rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ pub use error::{Error, FailureCode};
pub use messages::*;
pub use service_id::{ClientId, ServiceId, ServiceName};

pub const LNP_NODE_RPC_SOCKET: &str = "127.0.0.1:62962";
pub const LNP_NODE_RPC_ENDPOINT: &str = "0.0.0.0:62962";
19 changes: 11 additions & 8 deletions shell/_channeld
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ _channeld() {
_arguments "${_arguments_options[@]}" \
'-k+[Node key file]:KEY_FILE:_files' \
'--key-file=[Node key file]:KEY_FILE:_files' \
'-d+[<\[_\]<\[_\]>::into_vec(box \[$($x),+\]).into_iter().flatten() are located]:DATA_DIR:_files -/' \
'--data-dir=[<\[_\]<\[_\]>::into_vec(box \[$($x),+\]).into_iter().flatten() are located]:DATA_DIR:_files -/' \
'-d+[Data directory path]:DATA_DIR:_files -/' \
'--data-dir=[Data directory path]:DATA_DIR:_files -/' \
'-c+[Path for the configuration file]:CONFIG:_files' \
'--config=[Path for the configuration file]:CONFIG:_files' \
'-T+[Use Tor]:TOR_PROXY:_hosts' \
'--tor-proxy=[Use Tor]:TOR_PROXY:_hosts' \
'--msg=[ZMQ socket for internal message bus]:MSG_SOCKET:_files' \
'--ctl=[ZMQ socket for internal service bus]:CTL_SOCKET:_files' \
'-r+[ZMQ socket for connecting daemon RPC interface]:RPC_SOCKET: ' \
'--rpc=[ZMQ socket for connecting daemon RPC interface]:RPC_SOCKET: ' \
'-M+[ZMQ socket for peer message bus used to communicate with LNP node peerd service]:MSG_ENDPOINT:_files' \
'--msg=[ZMQ socket for peer message bus used to communicate with LNP node peerd service]:MSG_ENDPOINT:_files' \
'-X+[ZMQ socket for internal service control bus]:CTL_ENDPOINT:_files' \
'--ctl=[ZMQ socket for internal service control bus]:CTL_ENDPOINT:_files' \
'-R+[ZMQ socket for LNP Node client-server RPC API]:RPC_ENDPOINT: ' \
'--rpc=[ZMQ socket for LNP Node client-server RPC API]:RPC_ENDPOINT: ' \
'-n+[Blockchain to use]:CHAIN: ' \
'--chain=[Blockchain to use]:CHAIN: ' \
'--electrum-server=[Electrum server to use]:ELECTRUM_SERVER:_hosts' \
Expand All @@ -35,11 +37,12 @@ _channeld() {
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-R[Flag indicating that we are re-establishing a channel with the provided `channel_id`]' \
'-r[Flag indicating that we are re-establishing a channel with the provided `channel_id`]' \
'--reestablish[Flag indicating that we are re-establishing a channel with the provided `channel_id`]' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
'--threaded-daemons[Spawn daemons as threads and not processes]' \
'-t[Spawn daemons as threads and not processes]' \
'--threaded[Spawn daemons as threads and not processes]' \
':channel-id -- Channel id:' \
&& ret=0
}
Expand Down
19 changes: 11 additions & 8 deletions shell/_channeld.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ Register-ArgumentCompleter -Native -CommandName 'channeld' -ScriptBlock {
'channeld' {
[CompletionResult]::new('-k', 'k', [CompletionResultType]::ParameterName, 'Node key file')
[CompletionResult]::new('--key-file', 'key-file', [CompletionResultType]::ParameterName, 'Node key file')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, '<[_]<[_]>::into_vec(box [$($x),+]).into_iter().flatten() are located')
[CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, '<[_]<[_]>::into_vec(box [$($x),+]).into_iter().flatten() are located')
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path')
[CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path')
[CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path for the configuration file')
[CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path for the configuration file')
[CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor')
[CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor')
[CompletionResult]::new('--msg', 'msg', [CompletionResultType]::ParameterName, 'ZMQ socket for internal message bus')
[CompletionResult]::new('--ctl', 'ctl', [CompletionResultType]::ParameterName, 'ZMQ socket for internal service bus')
[CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'ZMQ socket for connecting daemon RPC interface')
[CompletionResult]::new('--rpc', 'rpc', [CompletionResultType]::ParameterName, 'ZMQ socket for connecting daemon RPC interface')
[CompletionResult]::new('-M', 'M', [CompletionResultType]::ParameterName, 'ZMQ socket for peer message bus used to communicate with LNP node peerd service')
[CompletionResult]::new('--msg', 'msg', [CompletionResultType]::ParameterName, 'ZMQ socket for peer message bus used to communicate with LNP node peerd service')
[CompletionResult]::new('-X', 'X', [CompletionResultType]::ParameterName, 'ZMQ socket for internal service control bus')
[CompletionResult]::new('--ctl', 'ctl', [CompletionResultType]::ParameterName, 'ZMQ socket for internal service control bus')
[CompletionResult]::new('-R', 'R', [CompletionResultType]::ParameterName, 'ZMQ socket for LNP Node client-server RPC API')
[CompletionResult]::new('--rpc', 'rpc', [CompletionResultType]::ParameterName, 'ZMQ socket for LNP Node client-server RPC API')
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Blockchain to use')
[CompletionResult]::new('--chain', 'chain', [CompletionResultType]::ParameterName, 'Blockchain to use')
[CompletionResult]::new('--electrum-server', 'electrum-server', [CompletionResultType]::ParameterName, 'Electrum server to use')
Expand All @@ -41,11 +43,12 @@ Register-ArgumentCompleter -Native -CommandName 'channeld' -ScriptBlock {
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
[CompletionResult]::new('-R', 'R', [CompletionResultType]::ParameterName, 'Flag indicating that we are re-establishing a channel with the provided `channel_id`')
[CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Flag indicating that we are re-establishing a channel with the provided `channel_id`')
[CompletionResult]::new('--reestablish', 'reestablish', [CompletionResultType]::ParameterName, 'Flag indicating that we are re-establishing a channel with the provided `channel_id`')
[CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'Set verbosity level')
[CompletionResult]::new('--verbose', 'verbose', [CompletionResultType]::ParameterName, 'Set verbosity level')
[CompletionResult]::new('--threaded-daemons', 'threaded-daemons', [CompletionResultType]::ParameterName, 'Spawn daemons as threads and not processes')
[CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'Spawn daemons as threads and not processes')
[CompletionResult]::new('--threaded', 'threaded', [CompletionResultType]::ParameterName, 'Spawn daemons as threads and not processes')
break
}
})
Expand Down
24 changes: 12 additions & 12 deletions shell/_lnp-cli
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ _lnp-cli() {

local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
Expand All @@ -38,7 +38,7 @@ _arguments "${_arguments_options[@]}" \
'--ip=[IPv4 or IPv6 address to bind to]:IP_ADDR: ' \
'-p+[Port to use; defaults to the native LN port]:PORT: ' \
'--port=[Port to use; defaults to the native LN port]:PORT: ' \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
Expand All @@ -48,7 +48,7 @@ _arguments "${_arguments_options[@]}" \
;;
(connect)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
Expand All @@ -59,7 +59,7 @@ _arguments "${_arguments_options[@]}" \
;;
(ping)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
Expand All @@ -70,7 +70,7 @@ _arguments "${_arguments_options[@]}" \
;;
(info)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
Expand All @@ -81,7 +81,7 @@ _arguments "${_arguments_options[@]}" \
;;
(funds)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
Expand All @@ -91,7 +91,7 @@ _arguments "${_arguments_options[@]}" \
;;
(peers)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
Expand All @@ -101,7 +101,7 @@ _arguments "${_arguments_options[@]}" \
;;
(channels)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
Expand All @@ -121,7 +121,7 @@ _arguments "${_arguments_options[@]}" \
'--htlc-min-value=[Indicates the smallest value of an HTLC this node will accept, in milli-satoshi]:HTLC_MIN_VALUE: ' \
'--htlc-max-total-value=[The maximum inbound HTLC value in flight towards this node, in milli-satoshi]:HTLC_MAX_TOTAL_VALUE: ' \
'--channel-reserve=[The minimum value unencumbered by HTLCs for the counterparty to keep in the channel, in satoshis]:CHANNEL_RESERVE: ' \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
Expand All @@ -133,7 +133,7 @@ _arguments "${_arguments_options[@]}" \
;;
(invoice)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
Expand All @@ -145,7 +145,7 @@ _arguments "${_arguments_options[@]}" \
;;
(pay)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
Expand All @@ -158,7 +158,7 @@ _arguments "${_arguments_options[@]}" \
;;
(help)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-R+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
Expand Down
Loading

0 comments on commit cfe49d3

Please sign in to comment.