11//! Command line arguments.
22
33use anyhow:: Context ;
4+ #[ cfg( feature = "clipboard" ) ]
45use arboard:: Clipboard ;
56use clap:: {
67 error:: { ContextKind , ErrorKind } ,
78 CommandFactory , Parser , Subcommand ,
89} ;
9- use console:: { style, Key , Term } ;
10+ use console:: style;
1011use data_encoding:: HEXLOWER ;
1112use futures_buffered:: BufferedStreamExt ;
1213use indicatif:: {
@@ -202,6 +203,7 @@ pub struct SendArgs {
202203 pub common : CommonArgs ,
203204
204205 /// Store the receive command in the clipboard.
206+ #[ cfg( feature = "clipboard" ) ]
205207 #[ clap( short = 'c' , long) ]
206208 pub clipboard : bool ,
207209}
@@ -652,20 +654,25 @@ async fn send(args: SendArgs) -> anyhow::Result<()> {
652654 println ! ( "to get this data, use" ) ;
653655 println ! ( "sendme receive {}" , ticket) ;
654656
655- // Add command to the clipboard
656- if args. clipboard {
657- add_to_clipboard ( & ticket) ;
658- }
657+ #[ cfg( feature = "clipboard" ) ]
658+ {
659+ use console:: { Key , Term } ;
659660
660- let _keyboard = tokio:: task:: spawn ( async move {
661- let term = Term :: stdout ( ) ;
662- println ! ( "press c to copy command to clipboard, or use the --clipboard argument" ) ;
663- loop {
664- if let Ok ( Key :: Char ( 'c' ) ) = term. read_key ( ) {
665- add_to_clipboard ( & ticket) ;
666- }
661+ // Add command to the clipboard
662+ if args. clipboard {
663+ add_to_clipboard ( & ticket) ;
667664 }
668- } ) ;
665+
666+ let _keyboard = tokio:: task:: spawn ( async move {
667+ let term = Term :: stdout ( ) ;
668+ println ! ( "press c to copy command to clipboard, or use the --clipboard argument" ) ;
669+ loop {
670+ if let Ok ( Key :: Char ( 'c' ) ) = term. read_key ( ) {
671+ add_to_clipboard ( & ticket) ;
672+ }
673+ }
674+ } ) ;
675+ }
669676
670677 tokio:: signal:: ctrl_c ( ) . await ?;
671678
@@ -678,6 +685,7 @@ async fn send(args: SendArgs) -> anyhow::Result<()> {
678685 Ok ( ( ) )
679686}
680687
688+ #[ cfg( feature = "clipboard" ) ]
681689fn add_to_clipboard ( ticket : & BlobTicket ) {
682690 let clipboard = Clipboard :: new ( ) ;
683691 match clipboard {
0 commit comments