SAHAJ 0.0.3
SAHAJ - Open Source Software Installation Helper
Requires Python: >=3.11
Keywords: installer, cli, opensource, automation, deployment

# SAHAJ

SAHAJ is an open-source CLI tool to install and manage open-source software easily.


## Requirements

* Python **3.11+**
* Git installed and available on `PATH`
* Docker (required for commands that start containers or use docker-compose)
* Recommended: a POSIX-like shell environment for running repo scripts (`bash`/`sh`)

## Installation

```bash
pip install SAHAJ
```

## Quick notes

* Global CLI entrypoint: `sahaj`
* Default repo folder used by commands: `./sahaj-opensource` (change with `--into <dir>`)
* User config file (created by `register`) is stored in the config directory (typically `~/.sahaj/config.json` on Unix). Use `SAHAJ_CONFIG_DIR` to override.

---

# Commands


## register

Interactive config wizard — creates `config.json` in your config dir (used by repo scripts and by `pull` copying).

```bash
sahaj register           # interactive prompts; use --overwrite to replace existing config.json
```

---

## pull (clone / update repo)

Clones the repo (if missing) or pulls updates from `origin/main`. Copies your global `config.json` into the cloned repo root (backups existing), and makes `.sh` files executable under `scripts` and `services`.

```
sahaj pull                     # clone into ./sahaj-opensource or pull updates if folder exists
sahaj pull --into my-folder    # clone/pull into specified folder
sahaj clone                    # alias for `sahaj pull`
```

Behavior on existing folder:

* Attempts `git pull origin main`.
* If local changes block merge, you will be prompted to discard local changes (forced reset) or abort.
* After clone/pull, user config is copied to `<repo>/config.json` (existing repo config is backed up).
* Makes `.sh` executable under `<repo>/scripts` and `<repo>/services`.

---

## rundev (dev environment)

Run repository-provided scripts located under `<repo>/scripts/*.sh`. All commands default to the repo folder `./sahaj-opensource` unless you pass `--into`.

### start

Run the repo `init-rundev` script. Requires `<repo>/config.json`.

```bash
sahaj rundev start
sahaj rundev start --into path/to/repo
```

### stop

Run the repo `stop-rundev` script. Optionally pass `-a` / `--clean-volumes` to remove volumes (passed as `-a` to the script).

```
sahaj rundev stop
sahaj rundev stop --into path/to/repo
sahaj rundev stop -a
```

If you omit `-a` the command prompts whether to clean volumes (recommended for fresh starts).

### restart

Stop (with volumes cleaned) then start:

```
sahaj rundev restart
```

### status

Runs `status-rundev` script (placeholder / implemented to invoke the repo status script):

```
sahaj rundev status
```

---

## deploy (production / builder workflows)

All deploy scripts are expected under `<repo>/scripts/*.sh`. Commands require a repo with `config.json` in repo root for start/build/full operations.

### full

Run combined build+deploy:

```bash
sahaj deploy full
sahaj deploy full --into path/to/repo
```

### build

Run the `build-images` script:

```bash
sahaj deploy build
```

### start

Run `deploy-all` (expects images built and config present):

```bash
sahaj deploy start
```

### stop

Run `stop-deployed`. Optionally pass `-a/--clean-volume` to remove volumes (script gets `-a`):

```bash
sahaj deploy stop
sahaj deploy stop -a
```

### reset

Run `clean-built-images` (removes built images). Use `--dry-run` to only show actions:

```bash
sahaj deploy reset         # actually run with confirmation semantics of underlying script
sahaj deploy reset --dry-run
```

### restart

Stop then start:

```bash
sahaj deploy restart
```

### status

Placeholder (keeps status behavior for future implementation):

```bash
sahaj deploy status
```

---

## quickstart

Quickstart is not implemented in this version:

```
sahaj quickstart
```

---

## Basic info & docs

```
sahaj version
sahaj license
sahaj about
sahaj docs
sahaj list
```

---

## Environment & config

* Global config created with `sahaj register` is copied into cloned repos by `sahaj pull`.
* Override config dir with `SAHAJ_CONFIG_DIR` if needed.

---

# Troubleshooting

* If `git` is not on `PATH`, `pull`/update will fail — install Git first.
* If `docker`/`docker-compose` are required by your repo scripts, ensure Docker is installed and running.
* On `git pull` conflicts you can choose to discard local changes (forced reset) or abort to handle conflicts manually.
* If a repository script is missing, commands will print `not found` and exit.

---

## Exit codes

* The CLI prints descriptive messages on failures; many subcommands return non-zero via underlying scripts when appropriate. Check stdout/stderr for script failure details.