Skip to content

Commit

Permalink
stderr up to 0.8.0 and app up to 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
biluohc committed Aug 12, 2017
1 parent a6d0945 commit 1baed68
Show file tree
Hide file tree
Showing 18 changed files with 299 additions and 67 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.o
*Cargo.lock
*.bk
*target
*main.html
239 changes: 239 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ toml = "^0.3.2"
serde_derive = "^0.9.14"
serde = "^0.9.14"

stderr ="0.7.1" # 要和 poolite 所用的同一个版本,否则loger不能正常工作。
poolite = "0.6.2"
app = "0.5.6"
stderr ="0.8.0" # 要和 poolite 所用的同一个版本,否则loger不能正常工作。
poolite = "0.6.3"
app = "0.6.0"

# stderr = { git = "https://github.com/biluohc/stderr", branch = "master", version = "0.7.0"}
# poolite = { git = "https://github.com/biluohc/poolite",branch = "master", version = "0.6.1" }
Expand Down
34 changes: 28 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# running fht2p --help(-h) to get help.

fht2p --help
fht2p -h
```
### Or
```sh
Expand All @@ -27,8 +27,30 @@

* [The Release Page](https://github.com/biluohc/fht2p/releases)

## Ps
* 0.0.0.0 is default listenning address.
* 8080 is default port.
* keep-alive is default close.
* ./ is default dir.
## Help
```sh
fht2p 0.8.0
A HTTP Server for Static File written with Rust

AUTHOR:
Wspsxing <biluohc@qq.com>

ADDRESS:
Github: https://github.com/biluohc/fht2p

USAGE:
fht2p [options] [<PATH>...]

OPTIONS:
-h, --help Show the help message
-V, --version Show the version message
-c, --config <config>(optional) Sets a custom config file
-C, --cp Print the default config file
-i, --ip <ip>[0.0.0.0] Sets listenning ip
-p, --port <port>[8080] Sets listenning port
-r, --rr Redirect root('/') to `/index.htm[l]`
-k, --ka <secs>(optional) Time HTTP keep alive(default not use)

ARGS:
<PATH>["./"] Sets the path to share
```
30 changes: 14 additions & 16 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ use toml;

use super::statics::*; // 名字,版本,作者,简介,地址

use app::{App, Opt};
use app::{App, Opt, Args};

/// Get `Config` by `parse` `args`
pub fn parse() -> Config {
let mut config = Config::default();
let mut server = Server::default();
let mut routes: Vec<String> = Vec::new();
let mut routes: Vec<String> = vec!["./".to_owned()];
let mut cp = false;
let mut c_path: Option<String> = None;

Expand All @@ -28,34 +28,33 @@ pub fn parse() -> Config {
.addr(URL_NAME, URL)
.desc(DESC)
.opt(Opt::new("cp", &mut cp)
.short("C")
.short('C')
.long("cp")
.help("Print the default config file"))
.opt(Opt::new("config", &mut c_path)
.optional()
.short("c")
.short('c')
.long("config")
.help("Sets a custom config file"))
.opt(Opt::new("root", &mut config.redirect_root)
.short("r")
.short('r')
.long("rr")
.help("Redirect root('/') to '/index.htm[l]`"))
.opt(Opt::new("secs", &mut config.keep_alive)
.short("k")
.short('k')
.long("ka")
.help("Time HTTP keep alive(default not use)")
.optional())
.opt(Opt::new("ip", &mut server.ip)
.short("i")
.short('i')
.long("ip")
.help("Sets listenning ip"))
.opt(Opt::new("port", &mut server.port)
.short("p")
.short('p')
.long("port")
.help("Sets listenning port"))
.args("PATHS", &mut routes)
.args_optional()
.args_help(r#"Sets the paths to share(default is "./")"#)
.args(Args::new("PATH", &mut routes)
.help(r#"Sets the path to share"#))
.parse_args()
};
// -cp/--cp
Expand All @@ -79,12 +78,11 @@ pub fn parse() -> Config {
None => Config::load_from_STR(),
}
} else {
config.servers.clear();
config.servers.push(SocketAddr::new(server.ip, server.port));
if !routes.is_empty() {
config.routes = args_paths_to_route(&routes[..])
.map_err(|e| helper.help_err_exit(e, 1))
.unwrap();
}
config.routes = args_paths_to_route(&routes[..])
.map_err(|e| helper.help_err_exit(e, 1))
.unwrap();
config
}
}
Expand Down
Loading

0 comments on commit 1baed68

Please sign in to comment.