Run 'cargo fmt' to format code (#489)
This commit is contained in:
committed by
Baptiste Gelez
parent
732f514da7
commit
b945d1f602
+29
-22
@@ -1,11 +1,7 @@
|
||||
use clap::{Arg, ArgMatches, App, SubCommand};
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
|
||||
use plume_models::{instance::*, safe_string::SafeString, Connection};
|
||||
use std::env;
|
||||
use plume_models::{
|
||||
Connection,
|
||||
instance::*,
|
||||
safe_string::SafeString,
|
||||
};
|
||||
|
||||
pub fn command<'a, 'b>() -> App<'a, 'b> {
|
||||
SubCommand::with_name("instance")
|
||||
@@ -42,22 +38,33 @@ pub fn run<'a>(args: &ArgMatches<'a>, conn: &Connection) {
|
||||
}
|
||||
|
||||
fn new<'a>(args: &ArgMatches<'a>, conn: &Connection) {
|
||||
let domain = args.value_of("domain").map(String::from)
|
||||
.unwrap_or_else(|| env::var("BASE_URL")
|
||||
.unwrap_or_else(|_| super::ask_for("Domain name")));
|
||||
let name = args.value_of("name").map(String::from).unwrap_or_else(|| super::ask_for("Instance name"));
|
||||
let license = args.value_of("default-license").map(String::from).unwrap_or_else(|| String::from("CC-BY-SA"));
|
||||
let domain = args
|
||||
.value_of("domain")
|
||||
.map(String::from)
|
||||
.unwrap_or_else(|| env::var("BASE_URL").unwrap_or_else(|_| super::ask_for("Domain name")));
|
||||
let name = args
|
||||
.value_of("name")
|
||||
.map(String::from)
|
||||
.unwrap_or_else(|| super::ask_for("Instance name"));
|
||||
let license = args
|
||||
.value_of("default-license")
|
||||
.map(String::from)
|
||||
.unwrap_or_else(|| String::from("CC-BY-SA"));
|
||||
let open_reg = !args.is_present("private");
|
||||
|
||||
Instance::insert(conn, NewInstance {
|
||||
public_domain: domain,
|
||||
name,
|
||||
local: true,
|
||||
long_description: SafeString::new(""),
|
||||
short_description: SafeString::new(""),
|
||||
default_license: license,
|
||||
open_registrations: open_reg,
|
||||
short_description_html: String::new(),
|
||||
long_description_html: String::new()
|
||||
}).expect("Couldn't save instance");
|
||||
Instance::insert(
|
||||
conn,
|
||||
NewInstance {
|
||||
public_domain: domain,
|
||||
name,
|
||||
local: true,
|
||||
long_description: SafeString::new(""),
|
||||
short_description: SafeString::new(""),
|
||||
default_license: license,
|
||||
open_registrations: open_reg,
|
||||
short_description_html: String::new(),
|
||||
long_description_html: String::new(),
|
||||
},
|
||||
)
|
||||
.expect("Couldn't save instance");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user