mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Update to clap 4
This commit is contained in:
parent
58bb4b5358
commit
94d79692df
4 changed files with 169 additions and 129 deletions
|
@ -1,34 +1,34 @@
|
|||
use clap::{crate_version, ArgEnum, Parser, Subcommand};
|
||||
use clap::{crate_version, Parser, Subcommand, ValueEnum};
|
||||
use std::{ffi::OsString, net::SocketAddr};
|
||||
|
||||
/// JSON-RPC client for signal-cli
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(rename_all = "kebab-case", version=crate_version!())]
|
||||
#[command(rename_all = "kebab-case", version=crate_version!())]
|
||||
pub struct Cli {
|
||||
/// Account to use (for daemon in multi-account mode)
|
||||
#[clap(short = 'a', long)]
|
||||
#[arg(short = 'a', long)]
|
||||
pub account: Option<String>,
|
||||
|
||||
/// TCP host and port of signal-cli daemon
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
pub json_rpc_tcp: Option<Option<SocketAddr>>,
|
||||
|
||||
/// UNIX socket address and port of signal-cli daemon
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
pub json_rpc_socket: Option<Option<OsString>>,
|
||||
|
||||
#[clap(arg_enum, long, default_value_t = OutputTypes::Json)]
|
||||
#[arg(value_enum, long, default_value_t = OutputTypes::Json)]
|
||||
pub output: OutputTypes,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
pub verbose: bool,
|
||||
|
||||
#[clap(subcommand)]
|
||||
#[command(subcommand)]
|
||||
pub command: CliCommands,
|
||||
}
|
||||
|
||||
#[derive(ArgEnum, Clone, Debug)]
|
||||
#[clap(rename_all = "kebab-case")]
|
||||
#[derive(ValueEnum, Clone, Debug)]
|
||||
#[value(rename_all = "kebab-case")]
|
||||
pub enum OutputTypes {
|
||||
PlainText,
|
||||
Json,
|
||||
|
@ -36,181 +36,181 @@ pub enum OutputTypes {
|
|||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Subcommand, Debug)]
|
||||
#[clap(rename_all = "camelCase", version=crate_version!())]
|
||||
#[command(rename_all = "camelCase", version=crate_version!())]
|
||||
pub enum CliCommands {
|
||||
AddDevice {
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
uri: String,
|
||||
},
|
||||
#[clap(rename_all = "kebab-case")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
Block {
|
||||
recipient: Vec<String>,
|
||||
|
||||
#[clap(short = 'g', long)]
|
||||
#[arg(short = 'g', long)]
|
||||
group_id: Vec<String>,
|
||||
},
|
||||
DeleteLocalAccountData {
|
||||
#[clap(long = "ignore-registered")]
|
||||
#[arg(long = "ignore-registered")]
|
||||
ignore_registered: Option<bool>,
|
||||
},
|
||||
GetUserStatus {
|
||||
recipient: Vec<String>,
|
||||
},
|
||||
JoinGroup {
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
uri: String,
|
||||
},
|
||||
Link {
|
||||
#[clap(short = 'n', long)]
|
||||
#[arg(short = 'n', long)]
|
||||
name: String,
|
||||
},
|
||||
ListAccounts,
|
||||
ListContacts {
|
||||
recipient: Vec<String>,
|
||||
#[clap(short = 'a', long = "all-recipients")]
|
||||
#[arg(short = 'a', long = "all-recipients")]
|
||||
all_recipients: bool,
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
blocked: Option<bool>,
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
name: Option<String>,
|
||||
},
|
||||
ListDevices,
|
||||
ListGroups {
|
||||
#[clap(short = 'd', long)]
|
||||
#[arg(short = 'd', long)]
|
||||
detailed: bool,
|
||||
#[clap(short = 'g', long = "group-id")]
|
||||
#[arg(short = 'g', long = "group-id")]
|
||||
group_id: Vec<String>,
|
||||
},
|
||||
ListIdentities {
|
||||
#[clap(short = 'n', long)]
|
||||
#[arg(short = 'n', long)]
|
||||
number: Option<String>,
|
||||
},
|
||||
ListStickerPacks,
|
||||
QuitGroup {
|
||||
#[clap(short = 'g', long = "group-id")]
|
||||
#[arg(short = 'g', long = "group-id")]
|
||||
group_id: String,
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
delete: bool,
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
admin: Vec<String>,
|
||||
},
|
||||
Receive {
|
||||
#[clap(short = 't', long, default_value_t = 3.0)]
|
||||
#[arg(short = 't', long, default_value_t = 3.0)]
|
||||
timeout: f64,
|
||||
},
|
||||
Register {
|
||||
#[clap(short = 'v', long)]
|
||||
#[arg(short = 'v', long)]
|
||||
voice: bool,
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
captcha: Option<String>,
|
||||
},
|
||||
RemoveContact {
|
||||
recipient: String,
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
forget: bool,
|
||||
},
|
||||
RemoveDevice {
|
||||
#[clap(short = 'd', long = "device-id")]
|
||||
#[arg(short = 'd', long = "device-id")]
|
||||
device_id: u32,
|
||||
},
|
||||
RemovePin,
|
||||
RemoteDelete {
|
||||
#[clap(short = 't', long = "target-timestamp")]
|
||||
#[arg(short = 't', long = "target-timestamp")]
|
||||
target_timestamp: u64,
|
||||
|
||||
recipient: Vec<String>,
|
||||
|
||||
#[clap(short = 'g', long = "group-id")]
|
||||
#[arg(short = 'g', long = "group-id")]
|
||||
group_id: Vec<String>,
|
||||
|
||||
#[clap(long = "note-to-self")]
|
||||
#[arg(long = "note-to-self")]
|
||||
note_to_self: bool,
|
||||
},
|
||||
#[clap(rename_all = "kebab-case")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
Send {
|
||||
recipient: Vec<String>,
|
||||
|
||||
#[clap(short = 'g', long)]
|
||||
#[arg(short = 'g', long)]
|
||||
group_id: Vec<String>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
note_to_self: bool,
|
||||
|
||||
#[clap(short = 'e', long)]
|
||||
#[arg(short = 'e', long)]
|
||||
end_session: bool,
|
||||
|
||||
#[clap(short = 'm', long)]
|
||||
#[arg(short = 'm', long)]
|
||||
message: Option<String>,
|
||||
|
||||
#[clap(short = 'a', long)]
|
||||
#[arg(short = 'a', long)]
|
||||
attachment: Vec<String>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
mention: Vec<String>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
quote_timestamp: Option<u64>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
quote_author: Option<String>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
quote_message: Option<String>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
quote_mention: Vec<String>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
sticker: Option<String>,
|
||||
},
|
||||
SendContacts,
|
||||
SendPaymentNotification {
|
||||
recipient: String,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
receipt: String,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
note: String,
|
||||
},
|
||||
SendReaction {
|
||||
recipient: Vec<String>,
|
||||
|
||||
#[clap(short = 'g', long = "group-id")]
|
||||
#[arg(short = 'g', long = "group-id")]
|
||||
group_id: Vec<String>,
|
||||
|
||||
#[clap(long = "note-to-self")]
|
||||
#[arg(long = "note-to-self")]
|
||||
note_to_self: bool,
|
||||
|
||||
#[clap(short = 'e', long)]
|
||||
#[arg(short = 'e', long)]
|
||||
emoji: String,
|
||||
|
||||
#[clap(short = 'a', long = "target-author")]
|
||||
#[arg(short = 'a', long = "target-author")]
|
||||
target_author: String,
|
||||
|
||||
#[clap(short = 't', long = "target-timestamp")]
|
||||
#[arg(short = 't', long = "target-timestamp")]
|
||||
target_timestamp: u64,
|
||||
|
||||
#[clap(short = 'r', long)]
|
||||
#[arg(short = 'r', long)]
|
||||
remove: bool,
|
||||
},
|
||||
SendReceipt {
|
||||
recipient: String,
|
||||
|
||||
#[clap(short = 't', long = "target-timestamp")]
|
||||
#[arg(short = 't', long = "target-timestamp")]
|
||||
target_timestamp: Vec<u64>,
|
||||
|
||||
#[clap(arg_enum, long)]
|
||||
#[arg(value_enum, long)]
|
||||
r#type: ReceiptType,
|
||||
},
|
||||
SendSyncRequest,
|
||||
SendTyping {
|
||||
recipient: Vec<String>,
|
||||
|
||||
#[clap(short = 'g', long = "group-id")]
|
||||
#[arg(short = 'g', long = "group-id")]
|
||||
group_id: Vec<String>,
|
||||
|
||||
#[clap(short = 's', long)]
|
||||
#[arg(short = 's', long)]
|
||||
stop: bool,
|
||||
},
|
||||
SetPin {
|
||||
|
@ -223,118 +223,118 @@ pub enum CliCommands {
|
|||
Trust {
|
||||
recipient: String,
|
||||
|
||||
#[clap(short = 'a', long = "trust-all-known-keys")]
|
||||
#[arg(short = 'a', long = "trust-all-known-keys")]
|
||||
trust_all_known_keys: bool,
|
||||
|
||||
#[clap(short = 'v', long = "verified-safety-number")]
|
||||
#[arg(short = 'v', long = "verified-safety-number")]
|
||||
verified_safety_number: Option<String>,
|
||||
},
|
||||
#[clap(rename_all = "kebab-case")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
Unblock {
|
||||
recipient: Vec<String>,
|
||||
|
||||
#[clap(short = 'g', long)]
|
||||
#[arg(short = 'g', long)]
|
||||
group_id: Vec<String>,
|
||||
},
|
||||
Unregister {
|
||||
#[clap(long = "delete-account")]
|
||||
#[arg(long = "delete-account")]
|
||||
delete_account: bool,
|
||||
},
|
||||
UpdateAccount {
|
||||
#[clap(short = 'n', long = "device-name")]
|
||||
#[arg(short = 'n', long = "device-name")]
|
||||
device_name: Option<String>,
|
||||
},
|
||||
UpdateConfiguration {
|
||||
#[clap(long = "read-receipts")]
|
||||
#[arg(long = "read-receipts")]
|
||||
read_receipts: Option<bool>,
|
||||
|
||||
#[clap(long = "unidentified-delivery-indicators")]
|
||||
#[arg(long = "unidentified-delivery-indicators")]
|
||||
unidentified_delivery_indicators: Option<bool>,
|
||||
|
||||
#[clap(long = "typing-indicators")]
|
||||
#[arg(long = "typing-indicators")]
|
||||
typing_indicators: Option<bool>,
|
||||
|
||||
#[clap(long = "link-previews")]
|
||||
#[arg(long = "link-previews")]
|
||||
link_previews: Option<bool>,
|
||||
},
|
||||
UpdateContact {
|
||||
recipient: String,
|
||||
|
||||
#[clap(short = 'e', long)]
|
||||
#[arg(short = 'e', long)]
|
||||
expiration: Option<u32>,
|
||||
|
||||
#[clap(short = 'n', long)]
|
||||
#[arg(short = 'n', long)]
|
||||
name: Option<String>,
|
||||
},
|
||||
UpdateGroup {
|
||||
#[clap(short = 'g', long = "group-id")]
|
||||
#[arg(short = 'g', long = "group-id")]
|
||||
group_id: Option<String>,
|
||||
|
||||
#[clap(short = 'n', long)]
|
||||
#[arg(short = 'n', long)]
|
||||
name: Option<String>,
|
||||
|
||||
#[clap(short = 'd', long)]
|
||||
#[arg(short = 'd', long)]
|
||||
description: Option<String>,
|
||||
|
||||
#[clap(short = 'a', long)]
|
||||
#[arg(short = 'a', long)]
|
||||
avatar: Option<String>,
|
||||
|
||||
#[clap(short = 'm', long)]
|
||||
#[arg(short = 'm', long)]
|
||||
member: Vec<String>,
|
||||
|
||||
#[clap(short = 'r', long = "remove-member")]
|
||||
#[arg(short = 'r', long = "remove-member")]
|
||||
remove_member: Vec<String>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
admin: Vec<String>,
|
||||
|
||||
#[clap(long = "remove-admin")]
|
||||
#[arg(long = "remove-admin")]
|
||||
remove_admin: Vec<String>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
ban: Vec<String>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
unban: Vec<String>,
|
||||
|
||||
#[clap(long = "reset-link")]
|
||||
#[arg(long = "reset-link")]
|
||||
reset_link: bool,
|
||||
|
||||
#[clap(arg_enum, long)]
|
||||
#[arg(value_enum, long)]
|
||||
link: Option<LinkState>,
|
||||
|
||||
#[clap(arg_enum, long = "set-permission-add-member")]
|
||||
#[arg(value_enum, long = "set-permission-add-member")]
|
||||
set_permission_add_member: Option<GroupPermission>,
|
||||
|
||||
#[clap(arg_enum, long = "set-permission-edit-details")]
|
||||
#[arg(value_enum, long = "set-permission-edit-details")]
|
||||
set_permission_edit_details: Option<GroupPermission>,
|
||||
|
||||
#[clap(arg_enum, long = "set-permission-send-messages")]
|
||||
#[arg(value_enum, long = "set-permission-send-messages")]
|
||||
set_permission_send_messages: Option<GroupPermission>,
|
||||
|
||||
#[clap(short = 'e', long)]
|
||||
#[arg(short = 'e', long)]
|
||||
expiration: Option<u32>,
|
||||
},
|
||||
UpdateProfile {
|
||||
#[clap(long = "given-name")]
|
||||
#[arg(long = "given-name")]
|
||||
given_name: Option<String>,
|
||||
|
||||
#[clap(long = "family-name")]
|
||||
#[arg(long = "family-name")]
|
||||
family_name: Option<String>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
about: Option<String>,
|
||||
|
||||
#[clap(long = "about-emoji")]
|
||||
#[arg(long = "about-emoji")]
|
||||
about_emoji: Option<String>,
|
||||
|
||||
#[clap(long = "mobile-coin-address")]
|
||||
#[arg(long = "mobile-coin-address")]
|
||||
mobile_coin_address: Option<String>,
|
||||
|
||||
#[clap(long)]
|
||||
#[arg(long)]
|
||||
avatar: Option<String>,
|
||||
|
||||
#[clap(long = "remove-avatar")]
|
||||
#[arg(long = "remove-avatar")]
|
||||
remove_avatar: bool,
|
||||
},
|
||||
UploadStickerPack {
|
||||
|
@ -343,29 +343,29 @@ pub enum CliCommands {
|
|||
Verify {
|
||||
verification_code: String,
|
||||
|
||||
#[clap(short = 'p', long)]
|
||||
#[arg(short = 'p', long)]
|
||||
pin: Option<String>,
|
||||
},
|
||||
Version,
|
||||
}
|
||||
|
||||
#[derive(ArgEnum, Clone, Debug)]
|
||||
#[clap(rename_all = "kebab-case")]
|
||||
#[derive(ValueEnum, Clone, Debug)]
|
||||
#[value(rename_all = "kebab-case")]
|
||||
pub enum ReceiptType {
|
||||
Read,
|
||||
Viewed,
|
||||
}
|
||||
|
||||
#[derive(ArgEnum, Clone, Debug)]
|
||||
#[clap(rename_all = "kebab-case")]
|
||||
#[derive(ValueEnum, Clone, Debug)]
|
||||
#[value(rename_all = "kebab-case")]
|
||||
pub enum LinkState {
|
||||
Enabled,
|
||||
EnabledWithApproval,
|
||||
Disabled,
|
||||
}
|
||||
|
||||
#[derive(ArgEnum, Clone, Debug)]
|
||||
#[clap(rename_all = "kebab-case")]
|
||||
#[derive(ValueEnum, Clone, Debug)]
|
||||
#[value(rename_all = "kebab-case")]
|
||||
pub enum GroupPermission {
|
||||
EveryMember,
|
||||
OnlyAdmins,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue