}
fn main() -> Result<(), Box<dyn error::Error>> {
- match check_ip() {
- Ok(()) => {
- let mut repo_name = String::new();
- io::stdin().read_line(&mut repo_name)?;
- // remove trailing newline
- repo_name.pop();
+ check_ip()?;
+ let mut repo_name = String::new();
+ io::stdin().read_line(&mut repo_name)?;
+ // remove trailing newline
+ repo_name.pop();
- let mut opts = git2::RepositoryInitOptions::new();
- git2::RepositoryInitOptions::bare(&mut opts, true)
- .mode(git2::RepositoryInitMode::SHARED_GROUP)
- .no_reinit(true)
- .template_path(path::Path::new("./templates"));
+ let mut opts = git2::RepositoryInitOptions::new();
+ git2::RepositoryInitOptions::bare(&mut opts, true)
+ .mode(git2::RepositoryInitMode::SHARED_GROUP)
+ .no_reinit(true)
+ .template_path(path::Path::new("./templates"));
- let repo = git2::Repository::init_opts(format!("{}.git", repo_name), &opts)?;
+ let repo = git2::Repository::init_opts(format!("{}.git", repo_name), &opts)?;
- let public_user = env::var("USER")?;
- let public_name = env::var("PUBLIC")?;
- let public_path = env::var("PATH")?;
- repo.remote(
- &public_name,
- &format!(
- "{user}@{public}:{path}/{repo}.git",
- user = public_user,
- public = public_name,
- path = public_path,
- repo = repo_name
- ),
- )?;
- Ok(())
- }
- Err(e) => Err(e),
- }
+ let public_user = env::var("USER")?;
+ let public_name = env::var("PUBLIC")?;
+ let public_path = env::var("PATH")?;
+ repo.remote(
+ "public",
+ &format!(
+ "{user}@{public}:{path}/{repo}.git",
+ user = public_user,
+ public = public_name,
+ path = public_path,
+ repo = repo_name
+ ),
+ )?;
+ Ok(())
}