# DAR-INVENIO-CLI

DAR-INVENIO-CLI is a command-line tool for creating drafts and uploading files in the Invenio webpage.

## Installation

### From PyPI (Recommended)
```bash
sudo apt install python3-full 
```

```bash
python3 -m venv venv
```

```bash
source venv/bin/activate
```

```bash
pip install <your-package>
```

### From source (for developers)

This guide will walk you through installing `dar-invenio-cli` from a cloned repository on Linux and Windows.

#### Prerequisites

- **Git:** You'll need Git to clone the repository. You can download it from [git-scm.com](https://git-scm.com/).
- **Python:** Python 3.8 or newer is required. You can download it from [python.org](https://www.python.org/).

#### Installation Steps

1.  **Install Python and venv:**
    ```bash
    sudo apt update
    sudo apt install python3 python3-pip python3-venv git
    ```

2.  **Clone the repository:**
    ```bash
    git clone git@gitlab.ics.muni.cz:dataraptors/elter/dar-invenio-cli.git
    cd dar-invenio-cli
    ```

3.  **Create and activate a virtual environment:**
    ```bash
    python3 -m venv .venv
    source .venv/bin/activate
    ```

4.  **Install the package:**
    ```bash
    pip install .
    ```

## Configuration

Before using the tool, you need to set up the configuration. The configuration with `api_token` is required.

```bash
dar-invenio-cli config init --api-token <your-api-token>
```

You can also update the values for `base-api-url` and `model` or `api_token` later:

```bash
dar-invenio-cli config update 
```
with optional options:
- `--base-api-url <your-base-api-url>`
- `--model <your-model>`
- `--api-token <your-api-token>`

You can see the current configuration by running:
```bash
dar-invenio-cli config show
```

## Usage

### Create a single draft

From a JSON file:
```bash
dar-invenio-cli create draft --from-file /path/to/your/file.json
```

From a name:
```bash
dar-invenio-cli create draft --from-name "My Draft Name"
```

### Create multiple drafts

From multiple JSON files:
```bash
dar-invenio-cli create drafts --from-files /path/to/file1.json /path/to/file2.json
```

From a folder containing JSON files:
```bash
dar-invenio-cli create drafts --from-folder /path/to/your/folder
```

### Upload files to a draft

```bash
dar-invenio-cli upload <draft_id> /path/to/file1 /path/to/file2
```

## For Developers

The core logic is located in `dar_invenio_cli/core.py`. You can import and use the functions from this module in your own Python projects.

## Deployment to PyPI

To deploy the package to PyPI, follow these steps:

1.  **Build the package:**

    ```bash
    python -m build
    ```

2.  **Install twine:**

    ```bash
    pip install twine
    ```

3.  **Upload to PyPI:**

    ```bash
    twine upload dist/*
    ```
