Metadata-Version: 2.4
Name: netrcli
Version: 0.0.1
Summary: Tool to work with .netrc file entries
Author-email: bugproduction <bugproduction@outlook.com>
License-Expression: MIT
Keywords: netrc,.netrc,GitLab,cli
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE.md
Dynamic: license-file

# netrcli - cli for .netrc file

netrcli is a small command line tool to work with entries in `.netrc` file. As the `.netrc` file support is implemented in many tools, like `ftp`, `curl`, `pip`, and `wget`, this tool targets to help the use of those tools with authenticated services, like GitLab.

> The credentials are stored in plaintext in the `.netrc` file.
>
> This is the way `.netrc` is. You have been warned.

In the background netrcli extends python standard library `netrc` implementation.

## Installation

Install the command line tool from with pipx:

```bash
pipx install netrcli
```

Alternatively use pip for the installation:

```bash
pip install netrcli
```

Either way, to check the installation and netrcli version, run:

```bash
netrcli --version
```

If you see a version in the terminal, you're good to go!

## Usage

When in doubt, try

```bash
netrcli --help
```

The tool uses `~/.netrc` file. If such does not exist, it will be created to the home directory of the current user.

### Updating entries in .netrc file

To add or modify the entry of `myhost.com` in the `.netrc` file, run

```bash
netrcli update --login user@name.com --password qwerty123 myhost.com
```

### Use in GitLab pipelines

To add GitLab credentials in the `.netrc` file during GitLab jobs, run

```bash
netrcli update --gitlab-ci
```

in the GitLab job. This adds an entry in the `.netrc` file with using environment variables `CI_SERVER_HOST` `CI_REGISTRY_USER`, and `CI_JOB_TOKEN`. Now you can use for example `curl` to fetch packages from GitLab package registry with just `--netrc` argument set.

> Note, that curl only supports HTTP basic authentication with the credentials from `.netrc` file with ``--netrc` argument.
> 
> Most of the endpoints in GitLab do not support HTTP basic authentication for authentication, but for example generic package registry does support it.

### Get information from .netrc file

To get a stored login (username) to the standard output for a specific host from the `.netrc` file, run

```bash
netrcli get --login myhost.com
```

And to get the stored password of the host, run:

```bash
netrcli get --password myhost.com
```
