feat: guess entryvalue in cli
parent
1dfa08c955
commit
d109809ad9
|
@ -68,7 +68,7 @@ enum Commands {
|
||||||
// The attribute.
|
// The attribute.
|
||||||
attribute: String,
|
attribute: String,
|
||||||
// The value.
|
// The value.
|
||||||
value: EntryValue,
|
value: String,
|
||||||
/// Output format
|
/// Output format
|
||||||
#[arg(short, long, default_value = "tsv")]
|
#[arg(short, long, default_value = "tsv")]
|
||||||
format: OutputFormat,
|
format: OutputFormat,
|
||||||
|
@ -201,16 +201,14 @@ fn main() -> Result<()> {
|
||||||
let url = url.unwrap_or("http://localhost:8093".parse().unwrap());
|
let url = url.unwrap_or("http://localhost:8093".parse().unwrap());
|
||||||
let api_url = url.join("/api/obj")?;
|
let api_url = url.join("/api/obj")?;
|
||||||
|
|
||||||
if let EntryValue::Invalid = value {
|
|
||||||
return Err(anyhow!("Invalid entry value."));
|
|
||||||
}
|
|
||||||
|
|
||||||
let entity = match entity {
|
let entity = match entity {
|
||||||
entity if entity.starts_with('=') => hash_path(&entity[1..])?.to_string(),
|
entity if entity.starts_with('=') => hash_path(&entity[1..])?.to_string(),
|
||||||
entity if entity.starts_with("http") => Address::Url(entity).to_string(),
|
entity if entity.starts_with("http") => Address::Url(entity).to_string(),
|
||||||
_ => entity,
|
_ => entity,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let value = EntryValue::guess_from(value);
|
||||||
|
|
||||||
let body = json!({
|
let body = json!({
|
||||||
"entity": entity,
|
"entity": entity,
|
||||||
"attribute": attribute,
|
"attribute": attribute,
|
||||||
|
|
Loading…
Reference in New Issue