11use std:: net:: IpAddr ;
22use std:: process:: exit;
3+ use std:: str:: FromStr ;
34use std:: sync:: Arc ;
45
56use anyhow:: Result ;
@@ -12,6 +13,24 @@ use crate::server::Server;
1213
1314const THREAD_NAME : & str = "http-server" ;
1415
16+ #[ derive( Clone , Debug , Parser ) ]
17+ pub enum Service {
18+ FileServer ,
19+ FileExplorer ,
20+ }
21+
22+ impl FromStr for Service {
23+ type Err = String ;
24+
25+ fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
26+ match s {
27+ "file-server" => Ok ( Service :: FileServer ) ,
28+ "file-explorer" => Ok ( Service :: FileExplorer ) ,
29+ _ => Err ( format ! ( "Invalid service: {}" , s) ) ,
30+ }
31+ }
32+ }
33+
1534#[ derive( Debug , Parser ) ]
1635pub struct StartOpt {
1736 /// Host (IP) to bind the server
@@ -23,9 +42,9 @@ pub struct StartOpt {
2342 /// Enable CORS with a permissive policy
2443 #[ clap( long, default_value = "false" ) ]
2544 pub cors : bool ,
26- /// Use widely supported File Explorer UI
27- #[ clap( long, default_value = "false " ) ]
28- pub legacy_ui : bool ,
45+ /// Service to run
46+ #[ clap( long, default_value = "file-explorer " ) ]
47+ pub service : Service ,
2948}
3049
3150impl From < & StartOpt > for Config {
@@ -34,7 +53,7 @@ impl From<&StartOpt> for Config {
3453 host : val. host ,
3554 port : val. port ,
3655 cors : val. cors ,
37- legacy_ui : val. legacy_ui ,
56+ service : val. service . clone ( ) . into ( ) ,
3857 }
3958 }
4059}
0 commit comments