|
1 | | -# gojuliahub |
| 1 | +# JuliaHub CLI (`jh`) |
| 2 | + |
| 3 | +A command-line interface for interacting with JuliaHub, a platform for Julia computing that provides dataset management, job execution, project management, Git integration, and package hosting capabilities. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Authentication**: OAuth2 device flow authentication with JWT token handling |
| 8 | +- **Dataset Management**: List, download, upload, and check status of datasets |
| 9 | +- **Project Management**: List and filter projects using GraphQL API |
| 10 | +- **Git Integration**: Clone, push, fetch, and pull with automatic JuliaHub authentication |
| 11 | +- **Julia Integration**: Install Julia and run with JuliaHub package server configuration |
| 12 | +- **User Management**: Display user information and profile details |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +### Download Binary |
| 17 | + |
| 18 | +Download the latest release from the [GitHub releases page](https://github.com/yourusername/jh/releases). |
| 19 | + |
| 20 | +Available for: |
| 21 | + |
| 22 | +- Linux (amd64, arm64) |
| 23 | +- macOS (amd64, arm64) |
| 24 | +- Windows (amd64, arm64) |
| 25 | + |
| 26 | +### Build from Source |
| 27 | + |
| 28 | +```bash |
| 29 | +git clone https://github.com/yourusername/jh |
| 30 | +cd jh |
| 31 | +go build -o jh . |
| 32 | +``` |
| 33 | + |
| 34 | +## Quick Start |
| 35 | + |
| 36 | +1. **Authenticate with JuliaHub:** |
| 37 | + |
| 38 | + ```bash |
| 39 | + jh auth login |
| 40 | + ``` |
| 41 | + |
| 42 | +2. **List your datasets:** |
| 43 | + |
| 44 | + ```bash |
| 45 | + jh dataset list |
| 46 | + ``` |
| 47 | + |
| 48 | +3. **List your projects:** |
| 49 | + |
| 50 | + ```bash |
| 51 | + jh project list |
| 52 | + ``` |
| 53 | + |
| 54 | +4. **Clone a project:** |
| 55 | + |
| 56 | + ```bash |
| 57 | + jh clone username/project-name |
| 58 | + ``` |
| 59 | + |
| 60 | +5. **Setup Git credential helper** (recommended for seamless Git operations): |
| 61 | + ```bash |
| 62 | + jh git-credential setup |
| 63 | + # Now you can use standard Git commands with JuliaHub repositories |
| 64 | + git clone https://juliahub.com/git/projects/username/project.git |
| 65 | + ``` |
| 66 | + |
| 67 | +## Commands |
| 68 | + |
| 69 | +### Authentication (`jh auth`) |
| 70 | + |
| 71 | +- `jh auth login` - Login to JuliaHub using OAuth2 device flow |
| 72 | +- `jh auth refresh` - Refresh authentication token |
| 73 | +- `jh auth status` - Show authentication status |
| 74 | +- `jh auth env` - Print environment variables for authentication |
| 75 | + |
| 76 | +### Dataset Management (`jh dataset`) |
| 77 | + |
| 78 | +- `jh dataset list` - List all accessible datasets |
| 79 | +- `jh dataset download <dataset-id> [version] [local-path]` - Download a dataset |
| 80 | +- `jh dataset upload [dataset-id] <file-path>` - Upload a dataset |
| 81 | +- `jh dataset status <dataset-id> [version]` - Show dataset status |
| 82 | + |
| 83 | +### Project Management (`jh project`) |
| 84 | + |
| 85 | +- `jh project list` - List all accessible projects |
| 86 | +- `jh project list --user` - List only your projects |
| 87 | +- `jh project list --user <username>` - List specific user's projects |
| 88 | + |
| 89 | +### Git Credential Helper (Recommended) |
| 90 | + |
| 91 | +- `jh git-credential setup` - Configure Git to use JuliaHub authentication |
| 92 | +- After setup, use standard Git commands: `git clone`, `git push`, `git pull` |
| 93 | + |
| 94 | +### Git Operations |
| 95 | + |
| 96 | +- `jh clone <username/project> [local-path]` - Clone a JuliaHub project by username/project name |
| 97 | +- `jh push [git-args...]` - Push with authentication |
| 98 | +- `jh fetch [git-args...]` - Fetch with authentication |
| 99 | +- `jh pull [git-args...]` - Pull with authentication |
| 100 | + |
| 101 | +### Julia Integration |
| 102 | + |
| 103 | +- `jh julia install` - Install Julia programming language |
| 104 | +- `jh run` - Start Julia with JuliaHub configuration |
| 105 | + |
| 106 | +### User Information (`jh user`) |
| 107 | + |
| 108 | +- `jh user info` - Show detailed user information |
| 109 | + |
| 110 | +## Configuration |
| 111 | + |
| 112 | +Configuration is stored in `~/.juliahub` with 0600 permissions. The file contains: |
| 113 | + |
| 114 | +- Server configuration |
| 115 | +- Authentication tokens (access, refresh, ID tokens) |
| 116 | +- User information (name, email) |
| 117 | + |
| 118 | +Default server: `juliahub.com` |
| 119 | + |
| 120 | +## Examples |
| 121 | + |
| 122 | +### Dataset Operations |
| 123 | + |
| 124 | +```bash |
| 125 | +# List datasets |
| 126 | +jh dataset list |
| 127 | + |
| 128 | +# Download latest version of a dataset |
| 129 | +jh dataset download my-dataset |
| 130 | + |
| 131 | +# Download specific version |
| 132 | +jh dataset download username/dataset-name v2 |
| 133 | + |
| 134 | +# Upload new dataset |
| 135 | +jh dataset upload --new ./my-data.tar.gz |
| 136 | + |
| 137 | +# Upload new version to existing dataset |
| 138 | +jh dataset upload my-dataset ./updated-data.tar.gz |
| 139 | +``` |
| 140 | + |
| 141 | +### Project Operations |
| 142 | + |
| 143 | +```bash |
| 144 | +# List all projects you have access to |
| 145 | +jh project list |
| 146 | + |
| 147 | +# List only your projects |
| 148 | +jh project list --user |
| 149 | + |
| 150 | +# List projects by specific user |
| 151 | +jh project list --user alice |
| 152 | +``` |
| 153 | + |
| 154 | +### Git Workflow |
| 155 | + |
| 156 | +```bash |
| 157 | +# Option 1: Use JuliaHub CLI wrapper commands (resolves uuids for you) |
| 158 | +jh clone alice/my-project |
| 159 | +cd my-project |
| 160 | +# Make changes... |
| 161 | +jh push |
| 162 | + |
| 163 | +# Option 2: Use Git credential helper (recommended) |
| 164 | +jh git-credential setup |
| 165 | +git clone https://juliahub.com/git/projects/uuid |
| 166 | +cd my-project |
| 167 | +# Make changes... |
| 168 | +git push |
| 169 | +``` |
| 170 | + |
| 171 | +Note: It's recommended to use the git-credential helper, but you can still |
| 172 | +clone using `jh clone username/project-name`; otherwise you need the project's uuid |
| 173 | + |
| 174 | +## Architecture |
| 175 | + |
| 176 | +- **Built with Go** using the Cobra CLI framework |
| 177 | +- **Authentication**: OAuth2 device flow with JWT token management |
| 178 | +- **APIs**: REST API for datasets, GraphQL API for projects and user info |
| 179 | +- **Git Integration**: Seamless authentication via HTTP headers or credential helper |
| 180 | +- **Cross-platform**: Supports Windows, macOS, and Linux |
| 181 | + |
| 182 | +## Development |
| 183 | + |
| 184 | +### Build and Test |
| 185 | + |
| 186 | +```bash |
| 187 | +# Run tests |
| 188 | +go test ./... |
| 189 | + |
| 190 | +# Build |
| 191 | +go build -o jh . |
| 192 | + |
| 193 | +# Code quality checks |
| 194 | +go fmt ./... |
| 195 | +go vet ./... |
| 196 | +``` |
| 197 | + |
| 198 | +### Contributing |
| 199 | + |
| 200 | +1. Fork the repository |
| 201 | +2. Create a feature branch |
| 202 | +3. Make changes with tests |
| 203 | +4. Run `go fmt ./...` and `go vet ./...` |
| 204 | +5. Submit a pull request |
0 commit comments