support creating a namespace by letting the user type in a namespace. In the future while I replace dialouger I'll have a typeahead-style selection widget to let me unify these two functions
This commit is contained in:
parent
a3c6655db1
commit
ce003c18fb
22
src/main.rs
22
src/main.rs
@ -181,11 +181,28 @@ fn change_namespace(db_conn: &mut db::DbHandle, master_key: [u8; 32]) -> String
|
||||
namespaces[selection].name.to_owned()
|
||||
}
|
||||
|
||||
fn create_namespace(db_conn: &mut db::DbHandle, master_key: [u8; 32]) -> String {
|
||||
let namespace: String = Input::with_theme(&ColorfulTheme::default())
|
||||
.with_prompt("Namespace")
|
||||
.default("main".to_owned())
|
||||
.interact()
|
||||
.unwrap();
|
||||
namespace
|
||||
}
|
||||
|
||||
fn shell(db_conn: &mut db::DbHandle, master_key: [u8; 32], _namespace: &str) {
|
||||
let mut namespace: String = _namespace.to_owned();
|
||||
|
||||
loop {
|
||||
let selections = &["get", "list", "set", "generate", "change namespace", "exit"];
|
||||
let selections = &[
|
||||
"get",
|
||||
"list",
|
||||
"set",
|
||||
"generate",
|
||||
"change namespace",
|
||||
"create namespace",
|
||||
"exit",
|
||||
];
|
||||
let main_menu_prompt = format!("Main Menu ({})", namespace);
|
||||
|
||||
let selection = Select::with_theme(&ColorfulTheme::default())
|
||||
@ -202,6 +219,9 @@ fn shell(db_conn: &mut db::DbHandle, master_key: [u8; 32], _namespace: &str) {
|
||||
"change namespace" => {
|
||||
namespace = change_namespace(db_conn, master_key);
|
||||
}
|
||||
"create namespace" => {
|
||||
namespace = create_namespace(db_conn, master_key);
|
||||
}
|
||||
"exit" => break,
|
||||
_ => panic!("Unrecognized command"),
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user