File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ use std:: { fs, io, time:: Instant } ;
2
+
3
+ use spellbook:: Dictionary ;
4
+
5
+ macro_rules! usage {
6
+ ( ) => {
7
+ eprintln!( "Usage: load-dictionary path/to/dict.aff path/to/dict.dic" ) ;
8
+ eprintln!( " Note: some shells accept a syntax like path/to/dict.{{aff,dic}}" ) ;
9
+ std:: process:: exit( 1 ) ;
10
+ } ;
11
+ }
12
+
13
+ fn main ( ) -> io:: Result < ( ) > {
14
+ let mut args = std:: env:: args ( ) . skip ( 1 ) ;
15
+ let Some ( aff) = args. next ( ) else {
16
+ usage ! ( ) ;
17
+ } ;
18
+ let Some ( dic) = args. next ( ) else {
19
+ usage ! ( ) ;
20
+ } ;
21
+ let aff = fs:: read_to_string ( aff) ?;
22
+ let dic = fs:: read_to_string ( dic) ?;
23
+ let now = Instant :: now ( ) ;
24
+ match Dictionary :: new ( & aff, & dic) {
25
+ Ok ( _) => println ! ( "Compiled the dictionary in {:?}" , now. elapsed( ) ) ,
26
+ Err ( err) => eprintln ! ( "Failed to compile the dictionary: {err}" ) ,
27
+ }
28
+ Ok ( ( ) )
29
+ }
You can’t perform that action at this time.
0 commit comments