# pipconf

**Advanced pip configuration file manager — CLI written in Rust**

---

## Features

- 🔍 **Auto-discovery** of pip config files across all platforms (Windows, macOS, Linux, venv, conda)
- 📖 **Complete schema** of all known pip configuration keys with docs, types, defaults, and environment variable equivalents
- ✏️ **Read / write / set / unset / add / remove** values with full INI-multiline support
- ✅ **Validation** against the official pip config schema
- 💾 **Backup & restore** with auto-timestamped backups
- 🔀 **Merge, diff, export, import** between configs
- 🌍 **Environment variable** inspection
- 📤 **Export to** INI, JSON, TOML, shell env format
- 📥 **Import from** INI or JSON
- 🎨 **Colored output** with table, JSON, TOML, and plain formats

---

## Installation

```bash
cargo install pipconf
```

```bash
cargo install --path .
# or
cargo build --release && cp target/release/pipconf /usr/local/bin/
```

---

## Usage

```
pipconf [OPTIONS] <COMMAND>
```

### Global options

| Flag | Description |
|---|---|
| `-f, --file <PATH>` | Override config file path |
| `-o, --output <FORMAT>` | Output format: table, json, toml, ini, plain |
| `--no-color` | Suppress color output |
| `-v, --verbose` | Verbose output |

---

### Commands

#### `discover` / `find`
Show all pip config file paths for this platform, with existence and writability status.

```bash
pipconf discover
pipconf discover --existing
```

#### `list` / `show`
Show all current config values.

```bash
pipconf list
pipconf list --section global
pipconf list -o json
```

#### `get`
Get a specific key value.

```bash
pipconf get index-url
pipconf get --section install user
```

#### `set`
Set a configuration value.

```bash
pipconf set index-url https://pypi.tuna.tsinghua.edu.cn/simple
pipconf set --section global timeout 60
```

#### `unset`
Remove a key.

```bash
pipconf unset index-url
pipconf unset --section install user
```

#### `add`
Append to a multi-value key (e.g. `trusted-host`, `extra-index-url`).

```bash
pipconf add trusted-host pypi.example.com
pipconf add extra-index-url https://my.private.index/simple
```

#### `remove`
Remove a value from a multi-value key.

```bash
pipconf remove trusted-host pypi.example.com
```

#### `validate` / `check`
Validate config against the complete pip schema.

```bash
pipconf validate
pipconf validate --strict   # also warn about unknown keys
```

#### `backup`
Backup the config file.

```bash
pipconf backup
pipconf backup --dest /tmp/pip.conf.bak
```

#### `restore`
Restore from a backup.

```bash
pipconf restore /tmp/pip.conf.bak.20240101_120000
```

#### `edit`
Open config in `$EDITOR`.

```bash
pipconf edit
pipconf edit --editor nano
```

#### `path`
Print the config file path.

```bash
pipconf path
pipconf path --level all
pipconf path --level system
```

#### `schema` / `keys`
Show all known pip config keys with documentation.

```bash
pipconf schema
```

#### `init`
Create a new config with sensible defaults.

```bash
pipconf init
pipconf init --index-url https://pypi.tuna.tsinghua.edu.cn/simple
pipconf init --trusted-host pypi.tuna.tsinghua.edu.cn --force
```

#### `reset`
Reset config.

```bash
pipconf reset                    # reset everything (asks for confirmation)
pipconf reset --section global   # reset only [global]
pipconf reset --yes              # skip confirmation
```

#### `merge`
Merge another config file into the current one.

```bash
pipconf merge /path/to/other/pip.conf
pipconf merge other.conf --conflict overwrite
pipconf merge other.conf --conflict keep
```

#### `diff`
Compare two config files.

```bash
pipconf diff /path/to/other.conf
pipconf diff file_a.conf file_b.conf
```

#### `export`
Export config to various formats.

```bash
pipconf export                           # INI to stdout
pipconf export -f json -o pip.json
pipconf export -f toml -o pip.toml
pipconf export -f shell -o pip_env.sh   # shell export statements
```

#### `import`
Import config from a file or stdin.

```bash
pipconf import pip.json
pipconf import - < pip.ini              # from stdin
```

#### `env`
Show all pip-related environment variables and their current values.

```bash
pipconf env
```

---

## Platform Config File Locations

pipconf follows pip's own config file search order:

### Linux
| Level | Path |
|---|---|
| site | `$VIRTUAL_ENV/pip.conf` |
| user | `$XDG_CONFIG_HOME/pip/pip.conf` (default: `~/.config/pip/pip.conf`) |
| user (legacy) | `~/.pip/pip.conf` |
| system | `/etc/pip.conf` |
| system (XDG) | `/etc/xdg/pip/pip.conf` |
| env | `$PIP_CONFIG_FILE` |

### macOS
| Level | Path |
|---|---|
| site | `$VIRTUAL_ENV/pip.conf` |
| user | `~/Library/Application Support/pip/pip.conf` |
| user (XDG) | `~/.config/pip/pip.conf` |
| user (legacy) | `~/.pip/pip.conf` |
| system | `/Library/Application Support/pip/pip.conf` |
| system | `/etc/pip.conf` |
| env | `$PIP_CONFIG_FILE` |

### Windows
| Level | Path |
|---|---|
| site | `%VIRTUAL_ENV%\pip.ini` |
| user | `%APPDATA%\pip\pip.ini` |
| user (legacy) | `%HOMEPATH%\pip\pip.ini` |
| system | `%ProgramData%\pip\pip.ini` |
| env | `%PIP_CONFIG_FILE%` |

---

## License

MIT

## 👤 Author
        
[Hadi Cahyadi](mailto:cumulus13@gmail.com)
    

[![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/cumulus13)

[![Donate via Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/cumulus13)
 
[Support me on Patreon](https://www.patreon.com/cumulus13)