← open_datasets
cli argument parsing (argparse)python · communitycommunity · karma-rewarded● active

CLI Argument Parser Implementation

sponsor: Platform
connect to contribute →

Each item is a cli argument parser implementation example providing Task description, Parser builder (Python), Invocation sequence. Favour realistic, self-contained cases; avoid duplicating public benchmark examples or trivial ones.

karma / item
40 karma
capacity reserved / target
85 / 5,000
final accepted
60
contributors
2
license
CC-BY-4.0
Karma per final accepted item

Secured after final acceptance. It is added to your balance when this pool publishes after its shared review window closes cleanly. Rejected items do not qualify.

secured on acceptance40 karma
Community terms

Platform-authored spec, open on delivery.

publishes tohugging face
licenseCC-BY-4.0
Quality signals

Measured pipeline stats for this dataset. A dash means the platform does not publish that measure for this pool.

submitted items86
rejected items1
duplicate rate15%
contributors2
validators1

// dataset_type_samples

Illustrative samples authored for the CLI Argument Parsing (argparse) dataset type.

invocations
[
  {
    "argv": [
      "create",
      "--source",
      "/data"
    ],
    "outcome": "success",
    "expected_namespace": {
      "command": "create",
      "source": "/data",
      "compress": false
    }
  },
  {
    "argv": [
      "create",
      "--source",
      "/data",
      "--compress"
    ],
    "outcome": "success",
    "expected_namespace": {
      "command": "create",
      "source": "/data",
      "compress": true
    }
  },
  {
    "argv": [
      "restore",
      "--archive",
      "a.tar"
    ],
    "outcome": "success",
    "expected_namespace": {
      "command": "restore",
      "archive": "a.tar",
      "target": null
    }
  },
  {
    "argv": [
      "restore",
      "--archive",
      "a.tar",
      "--target",
      "/restore"
    ],
    "outcome": "success",
    "expected_namespace": {
      "command": "restore",
      "archive": "a.tar",
      "target": "/restore"
    }
  },
  {
    "argv": [],
    "outcome": "failure",
    "expected_exit_code": 2,
    "expected_error_substring": "required"
  },
  {
    "argv": [
      "create"
    ],
    "outcome": "failure",
    "expected_exit_code": 2,
    "expected_error_substring": "required"
  },
  {
    "argv": [
      "bogus"
    ],
    "outcome": "failure",
    "expected_exit_code": 2,
    "expected_error_substring": "invalid choice"
  }
]
solution_code
import argparse

def build_parser():
    p = argparse.ArgumentParser(prog="backupctl")
    sub = p.add_subparsers(dest="command", required=True)

    create_p = sub.add_parser("create")
    create_p.add_argument("--source", required=True)
    create_p.add_argument("--compress", action="store_true", default=False)

    restore_p = sub.add_parser("restore")
    restore_p.add_argument("--archive", required=True)
    restore_p.add_argument("--target", default=None)

    return p
task_description
A backup CLI tool "backupctl" with subcommands `create` and `restore` (use add_subparsers(dest="command", required=True)). The `create` subcommand takes --source (required string) and --compress (store_true flag, default False). The `restore` subcommand takes --archive (required string) and --target (optional string, default None).

// sample_item

Approved public samples for this CLI Argument Parsing (argparse) dataset. These are source artifacts attached to this program, not generated examples.

No public sample item is available for this dataset yet.
Ready to contribute to this dataset?
Contribute to this open pool. 40 karma is secured on each final acceptance and added to your balance after verified publication.
connect to contribute →