feat: add --ids-only flag to --list mode for scripting
Outputs one ID per line with no header. Errors if used with any mode other than --list. Works with both local and client (remote) list.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
/// including table, JSON, and YAML.
|
||||
use crate::config;
|
||||
use crate::modes::common::ColumnType;
|
||||
use crate::modes::common::{OutputFormat, apply_color, apply_table_attribute, format_size};
|
||||
use crate::modes::common::{apply_color, apply_table_attribute, format_size, OutputFormat};
|
||||
use crate::services::item_service::ItemService;
|
||||
use crate::services::types::ItemWithMeta;
|
||||
use anyhow::{Context, Result};
|
||||
@@ -104,6 +104,15 @@ pub fn mode_list(
|
||||
.collect();
|
||||
let items_with_meta = item_service.list_items(conn, tags, &meta_filter)?;
|
||||
|
||||
if settings.ids_only {
|
||||
for item_with_meta in &items_with_meta {
|
||||
if let Some(id) = item_with_meta.item.id {
|
||||
println!("{id}");
|
||||
}
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let output_format = crate::modes::common::settings_output_format(settings);
|
||||
|
||||
if output_format != OutputFormat::Table {
|
||||
|
||||
Reference in New Issue
Block a user