cloudable-cli
v3.0.2
Published
Intelligent AWS infrastructure recommendations for any codebase - analyze and deploy in minutes
Maintainers
Readme
Cloudable CLI
A command-line interface built with oclif for cloud operations and management.
Prerequisites
- Node.js 18 or higher
- npm (comes with Node.js)
Installation
From Source
Clone the repository and install dependencies:
git clone https://github.com/Jai-Dhiman/cloudable.git
cd cloudable
npm install
npm run buildGlobal Installation (for development)
npm linkAfter linking, you can run cloudable from anywhere.
Usage
Run the CLI
# Using the bin script
./bin/run.js [COMMAND]
# Or if linked globally
cloudable [COMMAND]Available Commands
# Show help
cloudable --help
# Show version
cloudable --version
# Run the hello command
cloudable hello
cloudable hello world
cloudable hello --name=YourNameDevelopment
Project Structure
cloudable/
�� bin/ # Entry point scripts
�� dev.js # Development mode (with ts-node)
�� run.js # Production mode
�� src/ # TypeScript source files
�� commands/ # CLI commands
�� hello.ts # Example command
�� dist/ # Compiled JavaScript (generated)
�� tsconfig.json # TypeScript configuration
�� package.json # Project metadata and dependenciesDevelopment Workflow
Make changes to files in
src/Run in development mode (auto-compiles TypeScript):
npm run dev [COMMAND] # or ./bin/dev.js [COMMAND]Build for production:
npm run buildRun production build:
npm run start [COMMAND] # or ./bin/run.js [COMMAND]
Adding a New Command
Option 1: Using oclif generator
npx oclif generate command mycommandOption 2: Manual creation
Create a new file in src/commands/:
// src/commands/mycommand.ts
import {Args, Command, Flags} from '@oclif/core'
export default class MyCommand extends Command {
static description = 'Description of your command'
static examples = [
'<%= config.bin %> <%= command.id %>',
]
static flags = {
force: Flags.boolean({char: 'f', description: 'Force the operation'}),
name: Flags.string({char: 'n', description: 'Name parameter'}),
}
static args = {
file: Args.string({description: 'File to process', required: true}),
}
async run(): Promise<void> {
const {args, flags} = await this.parse(MyCommand)
this.log(`Processing ${args.file}`)
if (flags.force) {
this.log('Forced mode enabled')
}
}
}Then build and run:
npm run build
./bin/run.js mycommand --helpCreating Nested Commands (Topics)
Organize related commands by creating subdirectories:
Adding Tests
Create test files alongside your commands:
# Install testing dependencies
npm install --save-dev @oclif/test mocha chai
# Create test file
mkdir -p test/commands
touch test/commands/mycommand.test.tsExample test:
import {expect, test} from '@oclif/test'
describe('mycommand', () => {
test
.stdout()
.command(['mycommand', 'file.txt'])
.it('runs mycommand', ctx => {
expect(ctx.stdout).to.contain('Processing file.txt')
})
})Configuration
The CLI configuration is in package.json under the oclif key:
{
"oclif": {
"bin": "cloudable",
"commands": "./dist/commands",
"dirname": "cloudable",
"topicSeparator": " "
}
}Scripts
npm run build- Compile TypeScript to JavaScriptnpm run dev- Run CLI in development modenpm run start- Run compiled CLInpm test- Run tests (when configured)
Resources
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes and commit:
git commit -am 'Add new feature' - Push to the branch:
git push origin feature/my-feature - Submit a pull request
License
ISC
Issues
Report issues at: https://github.com/Jai-Dhiman/cloudable/issues
