···2233// cargo-deps: argh = "0.1", cidr = "0.2.1"
4455-use argh::FromArgs;
66-use cidr::IpCidr;
77-85use std::net::IpAddr;
96use std::str::FromStr;
77+88+use argh::FromArgs;
99+use cidr::IpCidr;
10101111#[derive(FromArgs)]
1212#[argh(description = "Display the ip range for a CIDR and check if an ip falls within.")]
···1818 )]
1919 ip: Option<IpAddr>,
20202121- #[argh(
2222- positional,
2323- description = "CIDR to inspect",
2424- from_str_fn(parse_cidr)
2525- )]
2121+ #[argh(positional, description = "CIDR to inspect", from_str_fn(parse_cidr))]
2622 cidr: IpCidr,
2723}
28242925fn main() {
3026 let App { ip, cidr } = argh::from_env();
3127 println!(
3232- "CIDR {} has a range of: {} to {}",
3333- cidr,
3434- cidr.first_address(),
2828+ "CIDR {} has a range of: {} to {}",
2929+ cidr,
3030+ cidr.first_address(),
3531 cidr.last_address()
3632 );
37333834 println!("CIDR {} has a netmask of {}", cidr, cidr.mask());
3939-3535+4036 if let Some(ip) = ip {
4137 print!("IP {}", ip);
4238 let falls_within = cidr.contains(&ip);
···4642 print!(" does not fall ");
4743 }
48444949- println!("within {}", cidr);
4545+ println!("within {}", cidr);
5046 }
5147}
5248
+8-9
dbg_server
···2233// cargo-deps: argh = "0.1"
4455-use argh::FromArgs;
66-55+use std::io::{BufRead, BufReader};
76use std::net::TcpListener;
88-use std::io::BufRead;
99-use std::io::BufReader;
107use std::str;
88+99+use argh::FromArgs;
11101211#[derive(FromArgs)]
1312#[argh(description = "simple debug server which logs the data sent to it.")]
···3534 let stream = stream.expect("stream should be present");
3635 let mut stream = BufReader::new(stream);
37363838- // This is not the "best" way to get the data sent over
3939- // but it sure is the easiest :^)
4040- let data = stream.fill_buf().expect("should have data");
4141- let output = str::from_utf8(data).expect("should be able to parse data as text");
4242- println!("{}", output);
3737+ // This is not the "best" way to get the data sent over
3838+ // but it sure is the easiest :^)
3939+ let data = stream.fill_buf().expect("should have data");
4040+ let output = str::from_utf8(data).expect("should be able to parse data as text");
4141+ println!("{}", output);
4342 }
4443}
···2233// cargo-deps: argh = "0.1"
4455+use std::io::{BufRead, BufReader, Write};
66+use std::net::{Shutdown, TcpStream};
77+58use argh::FromArgs;
66-77-use std::net::Shutdown;
88-use std::net::TcpStream;
99-use std::io::BufRead;
1010-use std::io::BufReader;
1111-use std::io::Write;
1291310const FLUSH_COMMAND: &str = "FLUSHALL\r\n";
1411···3229 let address = format!("{}:{}", app.host, app.port);
3330 let mut stream = TcpStream::connect(address).expect("should be able to connect to redis");
34313535- stream.write(FLUSH_COMMAND.as_bytes()).expect("should be able to write flush command");
3636- stream.flush().expect("should be able to send flush command");
3737- stream.shutdown(Shutdown::Write).expect("should be able to shutdown writer");
3232+ stream
3333+ .write(FLUSH_COMMAND.as_bytes())
3434+ .expect("should be able to write flush command");
3535+ stream
3636+ .flush()
3737+ .expect("should be able to send flush command");
3838+ stream
3939+ .shutdown(Shutdown::Write)
4040+ .expect("should be able to shutdown writer");
38413942 let mut stream = BufReader::new(stream);
40434144 let mut output = String::new();
4242- let _ = stream.read_line(&mut output).expect("should be able to read response");
4545+ let _ = stream
4646+ .read_line(&mut output)
4747+ .expect("should be able to read response");
4348 println!("{}", &output);
4449}
···2233// cargo-deps: argh = "0.1"
4455-use argh::FromArgs;
66-75use std::process::{self, Command};
66+77+use argh::FromArgs;
8899#[derive(FromArgs)]
1010#[argh(description = "Simple program to kill a process listening on a specific port.")]
···2233// cargo-deps: argh = "0.1", humantime = "2.1.0"
4455-use argh::FromArgs;
66-75use std::thread;
86use std::time::{Duration, Instant};
77+88+use argh::FromArgs;
991010#[derive(FromArgs)]
1111#[argh(description = "Keep track of how long a task runs or set a timer for some period of time.")]
···1919fn main() {
2020 let app: App = argh::from_env();
21212222-2323- let tag = Utc::now().format(&app.format).to_string();
2222+ let tag = Utc::now().format(&app.format).to_string();
24232524 println!("# Run the following to tag and release this version");
2625 println!();