File tree 3 files changed +395
-152
lines changed
3 files changed +395
-152
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " leth"
3
- version = " 0.2 .0"
3
+ version = " 0.3 .0"
4
4
authors = [" fcd <femnad@users.noreply.github.com>" ]
5
5
edition = " 2018"
6
6
@@ -9,3 +9,4 @@ edition = "2018"
9
9
[dependencies ]
10
10
regex = " 1"
11
11
skim = " 0.7.0"
12
+ structopt = " 0.3.26"
Original file line number Diff line number Diff line change 1
1
extern crate regex;
2
2
extern crate skim;
3
+ extern crate structopt;
3
4
4
5
use std:: collections:: HashMap ;
5
6
use std:: io:: Cursor ;
@@ -8,10 +9,17 @@ use std::process::Command;
8
9
9
10
use regex:: Regex ;
10
11
use skim:: { Skim , SkimOptionsBuilder } ;
12
+ use structopt:: StructOpt ;
11
13
12
14
const URL_REGEX : & str = r"(http(s)?://[a-zA-Z0-9_/?+&.=@%#;~-]+)" ;
13
15
16
+ #[ derive( Debug , StructOpt ) ]
17
+ #[ structopt( name = "leth" , about = "URL extractor intended to be used within mutt" ) ]
18
+ struct Opt { }
19
+
14
20
pub fn main ( ) {
21
+ Opt :: from_args ( ) ;
22
+
15
23
let options = SkimOptionsBuilder :: default ( )
16
24
. multi ( true )
17
25
. bind ( vec ! [ "ctrl-k:kill-line" ] )
@@ -37,13 +45,10 @@ pub fn main() {
37
45
}
38
46
}
39
47
40
- let mut ordered_items: Vec < _ > = matches. into_iter ( )
41
- . collect ( ) ;
48
+ let mut ordered_items: Vec < _ > = matches. into_iter ( ) . collect ( ) ;
42
49
ordered_items. sort_by ( |a, b| a. 1 . cmp ( & b. 1 ) ) ;
43
50
44
- let item_list: Vec < _ > = ordered_items. iter ( )
45
- . map ( |item|item. 0 )
46
- . collect ( ) ;
51
+ let item_list: Vec < _ > = ordered_items. iter ( ) . map ( |item| item. 0 ) . collect ( ) ;
47
52
let items = item_list. join ( "\n " ) ;
48
53
49
54
let selected_items = Skim :: run_with ( & options, Some ( Box :: new ( Cursor :: new ( items) ) ) )
You can’t perform that action at this time.
0 commit comments