follow.rs (591B)
1 use clap::ArgMatches; 2 3 use std::fs::OpenOptions; 4 use std::io::prelude::*; 5 use std::path::Path; 6 7 use crate::config::Config; 8 9 /// Follow new source by writing to the config file. 10 pub fn follow(_config: &Config, subcommand: &ArgMatches, config_path: &Path) { 11 let nick = subcommand.value_of("nick").unwrap(); 12 let url = subcommand.value_of("url").unwrap(); 13 // Appends given source to end of config file. 14 let mut config_file = OpenOptions::new().append(true).open(config_path).unwrap(); 15 config_file 16 .write_fmt(format_args!("\n{} = {}", nick, url)) 17 .unwrap(); 18 }