use std::{ffi::OsString, net::SocketAddr}; use clap::{crate_version, Parser, Subcommand, ValueEnum}; /// JSON-RPC client for signal-cli #[derive(Parser, Debug)] #[command(rename_all = "kebab-case", version = crate_version!())] pub struct Cli { /// Account to use (for daemon in multi-account mode) #[arg(short = 'a', long)] pub account: Option, /// TCP host and port of signal-cli daemon #[arg(long, conflicts_with = "json_rpc_http")] pub json_rpc_tcp: Option>, /// UNIX socket address and port of signal-cli daemon #[arg(long, conflicts_with = "json_rpc_tcp")] pub json_rpc_socket: Option>, /// HTTP URL of signal-cli daemon #[arg(long, conflicts_with = "json_rpc_socket")] pub json_rpc_http: Option>, #[arg(long)] pub verbose: bool, #[command(subcommand)] pub command: CliCommands, } #[allow(clippy::large_enum_variant)] #[derive(Subcommand, Debug)] #[command(rename_all = "camelCase", version = crate_version!())] pub enum CliCommands { AddDevice { #[arg(long)] uri: String, }, AddStickerPack { #[arg(long)] uri: String, }, #[command(rename_all = "kebab-case")] Block { recipient: Vec, #[arg(short = 'g', long)] group_id: Vec, }, DeleteLocalAccountData { #[arg(long = "ignore-registered")] ignore_registered: Option, }, FinishChangeNumber { number: String, #[arg(short = 'v', long = "verification-code")] verification_code: String, #[arg(short = 'p', long)] pin: Option, }, GetAttachment { #[arg(long)] id: String, #[arg(long)] recipient: Option, #[arg(short = 'g', long = "group-id")] group_id: Option, }, GetAvatar { #[arg(long)] contact: Option, #[arg(long)] profile: Option, #[arg(short = 'g', long = "group-id")] group_id: Option, }, GetSticker { #[arg(long = "pack-id")] pack_id: String, #[arg(long = "sticker-id")] sticker_id: u32, }, GetUserStatus { recipient: Vec, }, JoinGroup { #[arg(long)] uri: String, }, Link { #[arg(short = 'n', long)] name: String, }, ListAccounts, ListContacts { recipient: Vec, #[arg(short = 'a', long = "all-recipients")] all_recipients: bool, #[arg(long)] blocked: Option, #[arg(long)] name: Option, }, ListDevices, ListGroups { #[arg(short = 'd', long)] detailed: bool, #[arg(short = 'g', long = "group-id")] group_id: Vec, }, ListIdentities { #[arg(short = 'n', long)] number: Option, }, ListStickerPacks, QuitGroup { #[arg(short = 'g', long = "group-id")] group_id: String, #[arg(long)] delete: bool, #[arg(long)] admin: Vec, }, Receive { #[arg(short = 't', long, default_value_t = 3.0)] timeout: f64, }, Register { #[arg(short = 'v', long)] voice: bool, #[arg(long)] captcha: Option, }, RemoveContact { recipient: String, #[arg(long)] forget: bool, #[arg(long)] hide: bool, }, RemoveDevice { #[arg(short = 'd', long = "device-id")] device_id: u32, }, RemovePin, RemoteDelete { #[arg(short = 't', long = "target-timestamp")] target_timestamp: u64, recipient: Vec, #[arg(short = 'g', long = "group-id")] group_id: Vec, #[arg(long = "note-to-self")] note_to_self: bool, }, #[command(rename_all = "kebab-case")] Send { recipient: Vec, #[arg(short = 'g', long)] group_id: Vec, #[arg(long)] note_to_self: bool, #[arg(short = 'e', long)] end_session: bool, #[arg(short = 'm', long)] message: Option, #[arg(short = 'a', long)] attachment: Vec, #[arg(long)] mention: Vec, #[arg(long)] text_style: Vec, #[arg(long)] quote_timestamp: Option, #[arg(long)] quote_author: Option, #[arg(long)] quote_message: Option, #[arg(long)] quote_mention: Vec, #[arg(long)] quote_text_style: Vec, #[arg(long)] quote_attachment: Vec, #[arg(long)] preview_url: Option, #[arg(long)] preview_title: Option, #[arg(long)] preview_description: Option, #[arg(long)] preview_image: Option, #[arg(long)] sticker: Option, #[arg(long)] story_timestamp: Option, #[arg(long)] story_author: Option, #[arg(long)] edit_timestamp: Option, }, SendContacts, SendPaymentNotification { recipient: String, #[arg(long)] receipt: String, #[arg(long)] note: String, }, SendReaction { recipient: Vec, #[arg(short = 'g', long = "group-id")] group_id: Vec, #[arg(long = "note-to-self")] note_to_self: bool, #[arg(short = 'e', long)] emoji: String, #[arg(short = 'a', long = "target-author")] target_author: String, #[arg(short = 't', long = "target-timestamp")] target_timestamp: u64, #[arg(short = 'r', long)] remove: bool, #[arg(long)] story: bool, }, SendReceipt { recipient: String, #[arg(short = 't', long = "target-timestamp")] target_timestamp: Vec, #[arg(value_enum, long)] r#type: ReceiptType, }, SendSyncRequest, SendTyping { recipient: Vec, #[arg(short = 'g', long = "group-id")] group_id: Vec, #[arg(short = 's', long)] stop: bool, }, SendMessageRequestResponse { recipient: Vec, #[arg(short = 'g', long = "group-id")] group_id: Vec, r#type: MessageRequestResponseType, }, SetPin { pin: String, }, StartChangeNumber { number: String, #[arg(short = 'v', long)] voice: bool, #[arg(long)] captcha: Option, }, SubmitRateLimitChallenge { challenge: String, captcha: String, }, Trust { recipient: String, #[arg(short = 'a', long = "trust-all-known-keys")] trust_all_known_keys: bool, #[arg(short = 'v', long = "verified-safety-number")] verified_safety_number: Option, }, #[command(rename_all = "kebab-case")] Unblock { recipient: Vec, #[arg(short = 'g', long)] group_id: Vec, }, Unregister { #[arg(long = "delete-account")] delete_account: bool, }, UpdateAccount { #[arg(short = 'n', long = "device-name")] device_name: Option, #[arg(long = "unrestricted-unidentified-sender")] unrestricted_unidentified_sender: Option, #[arg(long = "discoverable-by-number")] discoverable_by_number: Option, #[arg(long = "number-sharing")] number_sharing: Option, }, UpdateConfiguration { #[arg(long = "read-receipts")] read_receipts: Option, #[arg(long = "unidentified-delivery-indicators")] unidentified_delivery_indicators: Option, #[arg(long = "typing-indicators")] typing_indicators: Option, #[arg(long = "link-previews")] link_previews: Option, }, UpdateContact { recipient: String, #[arg(short = 'e', long)] expiration: Option, #[arg(short = 'n', long)] name: Option, }, UpdateGroup { #[arg(short = 'g', long = "group-id")] group_id: Option, #[arg(short = 'n', long)] name: Option, #[arg(short = 'd', long)] description: Option, #[arg(short = 'a', long)] avatar: Option, #[arg(short = 'm', long)] member: Vec, #[arg(short = 'r', long = "remove-member")] remove_member: Vec, #[arg(long)] admin: Vec, #[arg(long = "remove-admin")] remove_admin: Vec, #[arg(long)] ban: Vec, #[arg(long)] unban: Vec, #[arg(long = "reset-link")] reset_link: bool, #[arg(value_enum, long)] link: Option, #[arg(value_enum, long = "set-permission-add-member")] set_permission_add_member: Option, #[arg(value_enum, long = "set-permission-edit-details")] set_permission_edit_details: Option, #[arg(value_enum, long = "set-permission-send-messages")] set_permission_send_messages: Option, #[arg(short = 'e', long)] expiration: Option, }, UpdateProfile { #[arg(long = "given-name")] given_name: Option, #[arg(long = "family-name")] family_name: Option, #[arg(long)] about: Option, #[arg(long = "about-emoji")] about_emoji: Option, #[arg(long = "mobile-coin-address", visible_alias = "mobilecoin-address")] mobile_coin_address: Option, #[arg(long)] avatar: Option, #[arg(long = "remove-avatar")] remove_avatar: bool, }, UploadStickerPack { path: String, }, Verify { verification_code: String, #[arg(short = 'p', long)] pin: Option, }, Version, } #[derive(ValueEnum, Clone, Debug)] #[value(rename_all = "kebab-case")] pub enum ReceiptType { Read, Viewed, } #[derive(ValueEnum, Clone, Debug)] #[value(rename_all = "kebab-case")] pub enum LinkState { Enabled, EnabledWithApproval, Disabled, } #[derive(ValueEnum, Clone, Debug)] #[value(rename_all = "kebab-case")] pub enum GroupPermission { EveryMember, OnlyAdmins, } #[derive(ValueEnum, Clone, Debug)] #[value(rename_all = "kebab-case")] pub enum MessageRequestResponseType { Accept, Delete, }