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
extern crate serde_json;
use crate::commands::kv;
use crate::commands::kv::key::KeyList;
use crate::settings::global_user::GlobalUser;
use crate::settings::target::Target;
pub fn list(
target: &Target,
user: &GlobalUser,
namespace_id: &str,
prefix: Option<&str>,
) -> Result<(), failure::Error> {
kv::validate_target(target)?;
let key_list = KeyList::new(target, user, namespace_id, prefix)?;
print!("[");
let mut first_key = true;
for key_result in key_list {
match key_result {
Ok(key) => {
if first_key {
first_key = false;
} else {
print!(",");
}
print!("{}", serde_json::to_string(&key)?);
}
Err(e) => print!("{}", kv::format_error(e)),
}
}
print!("]");
Ok(())
}