Compare commits
	
		
			3 Commits
		
	
	
		
			f572d6d8b2
			...
			a3c4a5f2dd
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								
									
								
								 | 
						a3c4a5f2dd | |
| 
							
							
								
									
								
								 | 
						a2f86770d1 | |
| 
							
							
								
									
								
								 | 
						cab4deca11 | 
| 
						 | 
					@ -13,7 +13,7 @@ pub struct Config {
 | 
				
			||||||
    pub repositories: Vec<Repository>,
 | 
					    pub repositories: Vec<Repository>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug, Serialize, Deserialize)]
 | 
					#[derive(Debug, Eq, PartialEq, Serialize, Deserialize)]
 | 
				
			||||||
/// The internal representation of a single repository
 | 
					/// The internal representation of a single repository
 | 
				
			||||||
pub struct Repository {
 | 
					pub struct Repository {
 | 
				
			||||||
    name: String,
 | 
					    name: String,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										26
									
								
								src/lib.rs
								
								
								
								
							
							
						
						
									
										26
									
								
								src/lib.rs
								
								
								
								
							| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
pub mod config;
 | 
					pub mod config;
 | 
				
			||||||
use config::{Config, Repository};
 | 
					use config::{Config, Repository};
 | 
				
			||||||
use std::error::Error;
 | 
					 | 
				
			||||||
use std::env;
 | 
					use std::env;
 | 
				
			||||||
 | 
					use std::error::Error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug)]
 | 
					#[derive(Debug)]
 | 
				
			||||||
/// Holds the current state of the application.
 | 
					/// Holds the current state of the application.
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,7 @@ pub struct State {
 | 
				
			||||||
enum Cmd {
 | 
					enum Cmd {
 | 
				
			||||||
    Add,
 | 
					    Add,
 | 
				
			||||||
    Help,
 | 
					    Help,
 | 
				
			||||||
 | 
					    Fetch,
 | 
				
			||||||
    DumpConfig,
 | 
					    DumpConfig,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,10 +81,19 @@ impl State {
 | 
				
			||||||
                        _ => {}
 | 
					                        _ => {}
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    None => {
 | 
					                    None => {
 | 
				
			||||||
                        eprintln!("No URL provided for \'number\' command\n");
 | 
					                        eprintln!("No URL provided for command\n");
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            // fetch command
 | 
				
			||||||
 | 
					            else if x == "fetch" {
 | 
				
			||||||
 | 
					                match state.cmd {
 | 
				
			||||||
 | 
					                    None => {
 | 
				
			||||||
 | 
					                        state.cmd = Some(Cmd::Fetch);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    _ => {}
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            arg = args.next();
 | 
					            arg = args.next();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -106,11 +116,17 @@ pub fn run(state: State, mut config: Config) -> Result<(), Box<dyn Error>> {
 | 
				
			||||||
            println!("{}", config.to_string().unwrap());
 | 
					            println!("{}", config.to_string().unwrap());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Some(Cmd::Add) => {
 | 
					        Some(Cmd::Add) => {
 | 
				
			||||||
            config.repositories.push(Repository::new(match state.url {
 | 
					            let repo = Repository::new(match state.url {
 | 
				
			||||||
                Some(x) => x,
 | 
					                Some(x) => x,
 | 
				
			||||||
                None => String::new(),
 | 
					                None => String::new(),
 | 
				
			||||||
            }));
 | 
					            });
 | 
				
			||||||
 | 
					            if let None = config.repositories.iter().find(|x| **x == repo) {
 | 
				
			||||||
 | 
					                config.repositories.push(repo);
 | 
				
			||||||
                config.save_config()?;
 | 
					                config.save_config()?;
 | 
				
			||||||
 | 
					                println!("Repository has been added");
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                println!("Repository is already being tracked");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Some(x) => {
 | 
					        Some(x) => {
 | 
				
			||||||
            println!("{:?} hasn't been implemented yet!", x)
 | 
					            println!("{:?} hasn't been implemented yet!", x)
 | 
				
			||||||
| 
						 | 
					@ -137,7 +153,7 @@ General
 | 
				
			||||||
    help    Print out this help message
 | 
					    help    Print out this help message
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Manage Repositories
 | 
					Manage Repositories
 | 
				
			||||||
    clone   Add another git repo to keep track of
 | 
					    add     Add another git repo to keep track of
 | 
				
			||||||
    fetch   Update currently tracked repos"
 | 
					    fetch   Update currently tracked repos"
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue