1
1
//! Command line arguments.
2
2
3
3
use anyhow:: Context ;
4
+ #[ cfg( feature = "clipboard" ) ]
4
5
use arboard:: Clipboard ;
5
6
use clap:: {
6
7
error:: { ContextKind , ErrorKind } ,
7
8
CommandFactory , Parser , Subcommand ,
8
9
} ;
9
- use console:: { style, Key , Term } ;
10
+ use console:: style;
10
11
use data_encoding:: HEXLOWER ;
11
12
use futures_buffered:: BufferedStreamExt ;
12
13
use indicatif:: {
@@ -202,6 +203,7 @@ pub struct SendArgs {
202
203
pub common : CommonArgs ,
203
204
204
205
/// Store the receive command in the clipboard.
206
+ #[ cfg( feature = "clipboard" ) ]
205
207
#[ clap( short = 'c' , long) ]
206
208
pub clipboard : bool ,
207
209
}
@@ -652,20 +654,25 @@ async fn send(args: SendArgs) -> anyhow::Result<()> {
652
654
println ! ( "to get this data, use" ) ;
653
655
println ! ( "sendme receive {}" , ticket) ;
654
656
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 } ;
659
660
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) ;
667
664
}
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
+ }
669
676
670
677
tokio:: signal:: ctrl_c ( ) . await ?;
671
678
@@ -678,6 +685,7 @@ async fn send(args: SendArgs) -> anyhow::Result<()> {
678
685
Ok ( ( ) )
679
686
}
680
687
688
+ #[ cfg( feature = "clipboard" ) ]
681
689
fn add_to_clipboard ( ticket : & BlobTicket ) {
682
690
let clipboard = Clipboard :: new ( ) ;
683
691
match clipboard {
0 commit comments