# UiPath CLI (`uip`)

A command-line interface tool for interacting with UiPath Cloud services. The CLI provides authentication, session management, and a plugin system for extending functionality with additional tools.

## Installation

### Using npm

```bash
npm install -g @uipath/cli
```

### Using bun

```bash
bun install -g @uipath/cli
```

After installation, the `uip` command will be available globally.

## Quick Start

1. **Login to UiPath Cloud**
   ```bash
   uip login
   ```

2. **Check your login status**
   ```bash
   uip login-status
   ```

3. **View available commands**
   ```bash
   uip --help
   ```

## Commands

### Authentication

#### `uip login`

Authenticate with UiPath Cloud using interactive OAuth login.

**Options:**
- `-f, --file <folder>` - Path to credentials folder (default: `.uipath`)
- `--authority <url>` - Custom authority URL
- `--client-id <id>` - Custom Client ID
- `-s, --scope <scopes>` - Custom scopes (space separated)
- `-t, --tenant <name>` - Tenant name (non-interactive mode)
- `--it, --interactive` - Interactively select tenant from list

**Examples:**
```bash
# Basic interactive login
uip login

# Login with custom credentials folder
uip login -f /path/to/my-folder

# Login with specific tenant
uip login -t my-tenant-name

# Interactive tenant selection
uip login --interactive
```

#### `uip login-status`

Display current login status and session information.

**Options:**
- `-f, --file <folder>` - Path to credentials folder (default: `.uipath`)

**Example:**
```bash
uip login-status
```

**Output:**
```
✅ Logged in
   Organization ID: abc123...
   Base URL: https://cloud.uipath.com
```

### Tool Management

The CLI supports a plugin system that allows you to extend functionality by installing additional tools.

#### `uip tools installed`

List all currently installed tools.

**Example:**
```bash
uip tools installed
```

**Output:**
```
🔧 Installed Tools:

  ✓ automation-tool v1.0.0
    Command: uip automation
    Automate workflows and processes
```

#### `uip tools search [query]`

Search for available tools in the configured registry.

**Example:**
```bash
# Search for tools
uip tools search automation

# Interactive search (prompts for query)
uip tools search
```

**Output:**
```
🔍 Searching for 'automation'...

📦 Found: @uipath/automation-tool (v1.0.0)
   Description: Automate workflows and processes
   Publisher: uipath

To install: uip tools install <package-name>
```

#### `uip tools install <package-name>`

Install a tool from the registry.

**Example:**
```bash
uip tools install @uipath/automation-tool
```

**Output:**
```
📦 Installing '@uipath/automation-tool'...
✅ Successfully installed @uipath/automation-tool
```

## Getting Help

- View all available commands: `uip --help`
- View help for a specific command: `uip <command> --help`
- View version: `uip --version`

## Troubleshooting

### Not logged in error

If you see `❌ Not logged in`, run `uip login` to authenticate.

### Tool not found after installation

After installing a new tool with `uip tools install`, you may need to restart your terminal or CLI session for the tool to become available.

### Authentication issues

If you're having trouble logging in, try:
1. Check your internet connection
2. Verify your credentials
3. Use `uip login --interactive` to manually select your tenant

## For Developers

### Development Setup

To work on the CLI locally:

```bash
# Install dependencies
bun install

# Run in development mode
bun run index.ts

# Build the project
bun run build

# Run tests
bun test
```

### Contributing

For bug reports and feature requests, please visit the [GitHub repository](https://github.com/UiPath/uipcli).

