feat: guess entryvalue in cli

feat/type-attributes
Tomáš Mládek 2023-05-04 18:54:17 +02:00
parent 1dfa08c955
commit d109809ad9
1 changed files with 3 additions and 5 deletions

View File

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