diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2862354..5c326a0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,6 @@ version: 2 updates: - package-ecosystem: "cargo" + directory: / schedule: interval: "daily" diff --git a/src/cli.rs b/src/cli.rs index 8e4ac4e..10d5184 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -72,23 +72,13 @@ impl From for log::LevelFilter { } } -#[derive(Debug, Args)] -pub struct TagsArgs { - /// The image name. - #[arg( - long, - num_args = 0..=1 - )] - pub(crate) name: String, -} - #[derive(Debug, Subcommand)] pub enum Commands { /// Fetch the list of available repositories from the catalog. Catalog, /// Fetch the list of tags for a given image. - Tags(TagsArgs), + Tags { name: String }, /// Perform a simple API Version check towards the configured registry /// endpoint. diff --git a/src/commands/catalog.rs b/src/commands/catalog.rs index fb59ed8..a6fdd23 100644 --- a/src/commands/catalog.rs +++ b/src/commands/catalog.rs @@ -16,8 +16,8 @@ //! Command module responsible for handling the "catalog" command. //! -//! The "catalog" command works with the Docker Registry API's "catalog" -//! entitity available at /v2/_catalog. +//! The "catalog" command works with the Docker Registry APIs "catalog" +//! entity available at /v2/_catalog. //! use serde::Deserialize; @@ -25,7 +25,7 @@ use crate::api; use crate::config::Config; use crate::error::ApiError; -/// Path to the Docker Registry API's "catalog" entity. +/// Path to the Docker Registry APIs "catalog" entity. const BASE_CATALOG_URI: &str = "/v2/_catalog"; /// Handler for the `Catalog` endpoint diff --git a/src/commands/tags.rs b/src/commands/tags.rs index 96c6092..4ddb8b8 100644 --- a/src/commands/tags.rs +++ b/src/commands/tags.rs @@ -16,17 +16,16 @@ //! Command module responsible for handling the "tags" command. //! -//! The "tags" command works with the Docker Registry API's "tags" -//! entitity available at /v2//tags/list. +//! The "tags" command works with the Docker Registry APIs "tags" +//! entity available at /v2//tags/list. //! use serde::Deserialize; use crate::api; -use crate::cli::TagsArgs; use crate::config::Config; use crate::error::ApiError; -/// Path to the Docker Registry API's "catalog" entity. +/// Path to the Docker Registry APIs "catalog" entity. const BASE_TAGS_URI: &str = "/v2/{name}/tags/list"; /// Handler for the `Tags` endpoint @@ -38,17 +37,15 @@ const BASE_TAGS_URI: &str = "/v2/{name}/tags/list"; /// /// Returns an `ApiError` if there is a problem fetching or parsing the /// responses from the Docker Registry API. -pub async fn handler(config: &Config, args: &TagsArgs) -> Result<(), ApiError> { +pub async fn handler(config: &Config, name: &str) -> Result<(), ApiError> { #[derive(Deserialize)] struct Response { - name: String, tags: Vec, } log::trace!("handler()"); - let name = args.name.clone(); - let url = BASE_TAGS_URI.replace("{name}", &name); + let url = BASE_TAGS_URI.replace("{name}", name); let responses: Vec = api::fetch_all(config, &url).await?; let tag_list: Vec<&str> = responses .iter() @@ -56,7 +53,7 @@ pub async fn handler(config: &Config, args: &TagsArgs) -> Result<(), ApiError> { .collect(); for tag in tag_list { - println!("{tag}"); + println!("{name}:{tag}"); } Ok(()) diff --git a/src/commands/version.rs b/src/commands/version.rs index a8b77a5..7402c17 100644 --- a/src/commands/version.rs +++ b/src/commands/version.rs @@ -17,12 +17,12 @@ //! Command module responsible for handling the API Version check. //! //! This is a minimal endpoint suitable for ensuring that the configured -//! Docker Regsitry API supports the correct API version. +//! Docker Registry API supports the correct API version. //! use crate::config::Config; use crate::error::ApiError; -/// Path to the Docker Registry API's "api version check" endpoint. +/// Path to the Docker Registry APIs "api version check" endpoint. const BASE_URL: &str = "/v2"; /// Handler for the API Version Check. diff --git a/src/main.rs b/src/main.rs index cf08f2a..d7ff806 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,7 @@ const CONFIG_PREFIX: &str = "dredge"; /// Locate the absolute path to the saved configuration file on disk. /// /// If given an optional `path` to a configuration file, and that file -/// exists on disk, the absoulte path to that file will be returned. +/// exists on disk, the absolute path to that file will be returned. /// Otherwise, the XDG configuration path will be used. If neither the /// optional `path` parameter refers to an existing file on disk, nor a /// suitable configuration file can be located within the XDG configuration @@ -75,7 +75,7 @@ fn locate_config_file(path: Option) -> Option { /// /// # Errors: /// -/// This returns a `ConfigError` if a problem occured which prevented either +/// This returns a `ConfigError` if a problem occurred which prevented either /// the creation of the directory tree, or in writing the default configuration /// to the file. fn create_default_config_file() -> Result { @@ -104,7 +104,7 @@ async fn main() -> Result<(), DredgeError> { let config = Config::try_from(config_file.as_ref())?; match args.command { Commands::Catalog => commands::catalog::handler(&config).await?, - Commands::Tags(args) => commands::tags::handler(&config, &args).await?, + Commands::Tags { name } => commands::tags::handler(&config, &name).await?, Commands::Check => commands::version::handler(&config).await?, }