Skip to content

Conversation

JR-1991
Copy link
Member

@JR-1991 JR-1991 commented Oct 7, 2025

This pull request refactors the CLI subcommand definitions throughout the codebase, replacing the deprecated structopt crate with the modern clap crate and its derive macros. It updates all subcommand enums to use clap::Subcommand and #[arg(...)] attributes, streamlining argument definitions and improving maintainability. Additionally, it introduces a wrapper type for file uploads in the dataset CLI to enhance type safety and parsing, and makes minor improvements to argument validation.

Migration from structopt to clap:

  • All CLI subcommand enums (AdminSubCommand, AuthSubCommand, CollectionSubCommand, DatasetSubCommand, FileSubCommand) now use #[derive(Subcommand, Debug)] and replace #[structopt(...)] attributes with #[arg(...)] for argument definitions, improving consistency and compatibility with the latest CLI standards. [1] [2] [3] [4] [5]
  • The structopt dependency is removed from Cargo.toml, and all use structopt::StructOpt; imports are replaced with use clap::Subcommand;. [1] [2] [3] [4] [5] [6]

CLI argument improvements and cleanup:

  • Command descriptions and argument help texts are streamlined for clarity, and legacy/deprecated attributes are removed or updated for all CLI subcommands. [1] [2] [3] [4] [5]
  • Argument validation for mutually exclusive options (e.g., required_unless_present) is updated to match the latest clap syntax, improving error handling and user feedback.

Dataset CLI enhancements:

  • A new wrapper type CliUploadFile is introduced for file uploads in DatasetSubCommand, improving type safety and parsing for file arguments. The upload logic is updated to use this wrapper type. [1] [2]

Other minor changes:

  • The crate name in Cargo.toml is changed from rust-dataverse to dvcli to better reflect the CLI tool's purpose.

Replaces structopt usage with clap throughout CLI modules for argument parsing and subcommand definitions. Updates derive macros, argument attributes, and adds custom styles for improved help output. Introduces a wrapper for file uploads in dataset CLI for better parsing and cloning.
Changed the crate name from 'rust-dataverse' to 'dvcli' in Cargo.toml and removed the structopt dependency. Updated Cargo.lock to reflect the removal of structopt and related packages, as well as the new crate name.
Added Clone derivation to DataFilePath, SearchType, SortField, and Order enums to enable cloning. Migrated SearchQuery struct and related macro usage from structopt to clap for argument parsing, updating attribute macros accordingly. Removed structopt imports and replaced with clap and lazy_static where needed.
@JR-1991 JR-1991 self-assigned this Oct 7, 2025
@JR-1991 JR-1991 added the enhancement New feature or request label Oct 7, 2025
@JR-1991 JR-1991 merged commit 5ba4417 into master Oct 7, 2025
7 checks passed
@JR-1991 JR-1991 deleted the migrate-to-clap branch October 7, 2025 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Development

Successfully merging this pull request may close these issues.

1 participant