CLI Usage
The NullScript CLI (nsc) provides powerful tools for developing with NullScript, from building and running files to advanced project management and analysis.
Installation
npm install -g nullscriptCommand Overview
The NullScript CLI is organized into logical command groups:
📦 BUILD & RUN
nsc build- Transpile NullScript files to JavaScriptnsc run- Execute NullScript files directlynsc convert- Convert JavaScript files to NullScript
🔧 PROJECT MANAGEMENT
nsc init- Initialize new NullScript projectsnsc config- Manage configuration files
💻 DEVELOPMENT
nsc dev- Development mode with file watchingnsc complete- Get code completion suggestionsnsc debug- Debug NullScript files with breakpoints
📊 ANALYSIS & INFO
nsc analyze- Analyze project performance and metricsnsc analytics- Show project analytics and statisticsnsc info- Display detailed file information
🎛️ UTILITIES
nsc keywords- Browse available keywords and mappingsnsc system- Show system information
Command Reference
nsc build
Transpile NullScript files to JavaScript:
# Transpile single file
nsc build hello.ns
# Transpile entire directory
nsc build src/
# Specify output directory
nsc build src/ --outDir distFeatures:
- Recursive directory processing
- Preserves directory structure
- Source map generation
- Error reporting with line numbers
nsc run
Execute NullScript files directly without pre-compilation:
nsc run hello.nsPerfect for:
- Quick testing and prototyping
- Running simple scripts
- Development and debugging
- One-off executions
nsc convert
Convert JavaScript files to NullScript syntax:
# Convert single file
nsc convert app.js
# Specify output file
nsc convert app.js --output app.ns
# Format the output
nsc convert app.js --format
# Show conversion report
nsc convert app.js --reportnsc init
Initialize new NullScript projects:
# Create new project in current directory
nsc init
# Create project with specific name
nsc init my-project
# Use project template
nsc init my-project --template basic
# Force initialization in non-empty directory
nsc init --forceAvailable Templates:
basic- Simple project structureweb- Web application templatenode- Node.js application templatelibrary- Library/package template
nsc config
Manage project configuration:
# Show current configuration
nsc config --show
# Generate default configuration file
nsc config --generate
# Validate configuration file
nsc config --validatensc dev
Development mode with file watching:
# Watch current directory
nsc dev
# Watch specific directory
nsc dev src/
# Watch and rebuild on changes
nsc dev src/ --watch
# Execute files when they change
nsc dev src/ --run-on-savensc complete
Get code completion suggestions (useful for IDE integration):
# Get completions for specific position
nsc complete src/app.ns --line 10 --column 5
# Output in different formats
nsc complete src/app.ns --line 10 --column 5 --format json
nsc complete src/app.ns --line 10 --column 5 --format textnsc debug
Debug NullScript files with advanced features:
# Debug with initial breakpoint
nsc debug app.ns --breakpoint 15
# Enable performance profiling
nsc debug app.ns --profilensc analyze
Analyze project performance and generate reports:
# Analyze current project
nsc analyze
# Analyze specific directory
nsc analyze src/
# Specify output directory for reports
nsc analyze src/ --output reports/
# Set bundle size limits
nsc analyze src/ --bundle-size-limit 1000000
# Set build time budget
nsc analyze src/ --build-time-budget 5000
# Generate different report formats
nsc analyze src/ --format html
nsc analyze src/ --format jsonAnalysis Features:
- Bundle size analysis
- Build time metrics
- Code complexity analysis
- Performance bottleneck detection
- Memory usage profiling
nsc analytics
Show project analytics and development statistics:
# Show analytics for current project
nsc analytics
# Analyze specific time period
nsc analytics --days 30
# Different output formats
nsc analytics --format text
nsc analytics --format jsonnsc analyze-clean
Clean up analysis reports:
# Clean default reports directory
nsc analyze-clean
# Clean specific directory
nsc analyze-clean --reports-dir custom-reports/
# Force removal without confirmation
nsc analyze-clean --forcensc info
Display detailed file and project information:
# Show basic file info
nsc info hello.ns
# Show detailed information
nsc info src/ --detailedInformation Displayed:
- File sizes and line counts
- Modification timestamps
- Project structure analysis
- NullScript file statistics
nsc keywords
Browse available keywords and their mappings:
# Show all keywords
nsc keywords
# Filter by category
nsc keywords --category "Control Flow"
nsc keywords --category "Functions & Methods"
nsc keywords --category "Console Methods"Available Categories:
Control Flow- Conditionals, loops, and flow controlVariables & Declarations- Variable declaration keywordsFunctions & Methods- Function-related keywordsOperators- Comparison and logical operatorsTypes & Classes- Object-oriented programmingConsole Methods- Console output methodsGlobal Objects- Built-in JavaScript objectsGlobal Functions- Global utility functionsTiming Functions- setTimeout, setInterval, etc.Boolean Values- true, false, null, undefinedModules & Imports- Import/export statementsError Handling- try, catch, finallyObject-Oriented- Classes, inheritance, objectsAsync/Await- Asynchronous programmingUtility- Utility keywords and operators
nsc system
Show system information and dependencies:
nsc system --infoSystem Check:
- Node.js availability and version
- NullScript CLI version
- System compatibility
Global Options
| Option | Short | Description |
|---|---|---|
--help | -h | Show help information |
--version | -v | Show version number |
Development Workflows
Quick Start Workflow
# Create a new project
nsc init my-app
cd my-app
# Run the generated example
nsc run src/main.ns
# Start development mode
nsc dev src/ --watchBuilding for Production
# Analyze your project first
nsc analyze src/
# Build optimized version
nsc build src/ --outDir dist
# Check build output
nsc info dist/ --detailedConverting Existing JavaScript
# Convert JavaScript to NullScript
nsc convert app.js --output app.ns --format
# Review conversion report
nsc convert app.js --report
# Test the converted file
nsc run app.nsDebugging Workflow
# Debug with breakpoint
nsc debug src/app.ns --breakpoint 25
# Profile performance
nsc debug src/app.ns --profile
# Complete code while editing
nsc complete src/app.ns --line 10 --column 5Advanced Features
Configuration Files
Create nullscript.config.json for project settings:
# Generate default configuration
nsc config --generate
# Validate existing configuration
nsc config --validate
# View current settings
nsc config --showProject Templates
Available project templates:
# Basic project structure
nsc init my-project --template basic
# Web application with HTML/CSS
nsc init my-webapp --template web
# Node.js backend application
nsc init my-api --template node
# Reusable library/package
nsc init my-lib --template libraryPerformance Analysis
Generate detailed performance reports:
# Full analysis with HTML report
nsc analyze src/ --format html --output reports/
# Set performance budgets
nsc analyze src/ --bundle-size-limit 500000 --build-time-budget 3000
# View project analytics
nsc analytics --days 7 --format jsonTips and Best Practices
Development Tips
- Use
nsc dev --watchfor real-time development - Set up project templates for consistent project structure
- Use
nsc analyzeregularly to catch performance issues early - Leverage
nsc completefor IDE integration - Keep
nullscript.config.jsonin version control
Performance Tips
- Monitor bundle sizes with
nsc analyze --bundle-size-limit - Profile builds using
nsc debug --profile - Clean up reports with
nsc analyze-cleanperiodically - Use analytics to track development patterns
Project Organization
my-nullscript-project/
├── src/ # Source files
│ ├── main.ns # Entry point
│ ├── utils/ # Utility modules
│ └── components/ # Reusable components
├── dist/ # Built output
├── reports/ # Analysis reports
├── nullscript.config.json
└── package.jsonTroubleshooting
Common Issues
Installation Issues:
# Clear npm cache and reinstall
npm cache clean --force
npm install -g nullscript
# Check installation
nsc --version
nsc system --infoBuild Errors:
# Get detailed error information
nsc build src/ --verbose
# Check file syntax
nsc keywords --category "Error Handling"
# Validate project structure
nsc info src/ --detailedPerformance Issues:
# Analyze bottlenecks
nsc analyze src/ --format html
# Clean up old reports
nsc analyze-clean --force
# Check system resources
nsc system --infoDevelopment Workflow Issues:
# Reset configuration
nsc config --generate --force
# Check file watching
nsc dev src/ --watch --verbose
# Verify file permissions
nsc info src/ --detailedGetting Help
- CLI Help:
nsc --helpornsc <command> --help - Documentation: NullScript Guide
- Keywords Reference:
nsc keywordsor Keywords Reference - System Info:
nsc system --info - GitHub Issues: Report bugs and feature requests
Integration
IDE Integration
The CLI provides language server features for IDE support:
# Get code completions (used by VS Code extension)
nsc complete file.ns --line 10 --column 5 --format json
# Debug integration
nsc debug file.ns --breakpoint 15CI/CD Integration
Example GitHub Actions workflow:
name: Build NullScript
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18"
- run: npm install -g nullscript
- run: nsc build src/
- run: nsc analyze src/ --bundle-size-limit 1000000Package.json Scripts
Add common commands to your package.json:
{
"scripts": {
"build": "nsc build src/ --outDir dist",
"dev": "nsc dev src/ --watch",
"analyze": "nsc analyze src/ --format html",
"debug": "nsc debug src/main.ns",
"convert": "nsc convert legacy.js --output legacy.ns"
}
}