summary refs log tree commit diff stats
path: root/tests/ccgbugs/tcapture_static.nim
Commit message (Expand)AuthorAgeFilesLines
* fixes #4551Andreas Rumpf2016-08-091-0/+13
de/instistats/commit/src/main.rs?h=only_user_count&id=194881ebf325f269891eb05c41c4bcf0baf3fed3'>194881e ^
674b999 ^
194881e ^
d210c2f ^
194881e ^
d210c2f ^

194881e ^
d210c2f ^





194881e ^
d210c2f ^


194881e ^
d210c2f ^








311eaad
d210c2f ^


674b999 ^










d210c2f ^
194881e ^





311eaad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
             
            
                 
 
                                    
               

                          
                                         





                                        
                            


                        
                             








                                        
           


                                                    










                                                                                                                          
               





                                                                                  
 
use std::env;
use std::fs;
use std::process;

use serde::{Deserialize, Serialize};
use serde_yaml;

const VERS: &str = "v0.1";
const CONF_PATH: &str = "instistats.yml";

#[derive(Debug, Deserialize, Serialize)]
struct Server {
    name: String,
    url: String,
    signup_url: String,
    user_count: Option<u32>,
    want_users: bool,
    admin_email: String,
    description: String,
    users: Option<Vec<User>>,
}

#[derive(Debug, Deserialize, Serialize)]
struct User {
    name: String,
    title: String,
    mtime: String,
}

fn main() {
    println!("instistats {}", VERS);
    println!("(c) 2019 Ben Morrison - ISC License");
    println!();
    let args = env::args().collect::<Vec<String>>();
    let out_path = match args[1].trim() {
        "-h" | "--help" => {
            println!("The only argument should be the path to save the tilde.json file.\nEx: /var/www/htdocs/tilde.json");
            process::exit(0);
        }
        out_path => {
            println!("Output Location: {}", out_path);
            out_path
        }
    };
    println!();

    let conf = fs::read_to_string(CONF_PATH).expect("Could not read config file");
    let conf_yaml: Server =
        serde_yaml::from_str(&conf).expect("Could not parse config data as YAML");

    println!("{:#?}", conf_yaml);
}