Add list subcommand
This commit is contained in:
parent
8c03ac337d
commit
04a45720ca
5 changed files with 19 additions and 0 deletions
|
@ -49,6 +49,9 @@ simple process
|
|||
3. Puts it in the `subject` field instead of the old subject
|
||||
4. Appends the old subject to the `aliases` array
|
||||
|
||||
### `list`
|
||||
Lists the subject field of every resource in the db
|
||||
|
||||
### `query`
|
||||
A simple command to get the response JSON to a query without `curl`. It pretty-prints the JSON.
|
||||
|
||||
|
|
|
@ -89,6 +89,8 @@ pub enum Command {
|
|||
#[command(flatten)]
|
||||
server_reload: ServerReloadOptions,
|
||||
},
|
||||
/// Lists all subjects in the database
|
||||
List {},
|
||||
/// Runs a single query against the database and returns the resource associated with the value
|
||||
Query {
|
||||
/// The resource to query for
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
pub mod editor;
|
||||
pub mod fetch;
|
||||
pub mod init;
|
||||
pub mod list;
|
||||
pub mod query;
|
||||
|
|
9
src/editor/commands/list.rs
Normal file
9
src/editor/commands/list.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use crate::schema::resource_list::ResourceList;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn list(database_path: PathBuf) {
|
||||
let resources = ResourceList::load(database_path).unwrap();
|
||||
for resource in resources.0 {
|
||||
println!("{}", resource.subject)
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
use crate::args_parser::Command;
|
||||
use crate::editor::commands::editor::editor;
|
||||
use crate::editor::commands::init::init;
|
||||
use crate::editor::commands::list::list;
|
||||
use crate::editor::try_reload_server::reload;
|
||||
use clap::Parser;
|
||||
use editor::commands::fetch::fetch;
|
||||
|
@ -67,5 +68,8 @@ fn main() {
|
|||
Command::Init { force } => {
|
||||
init(data_paths.database_path, force);
|
||||
}
|
||||
Command::List {} => {
|
||||
list(data_paths.database_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue