Summary
Currently, caution init creates apps with auto-generated names like app-fc8ccd2a. We should derive the app name from the current directory name, similar to how Fly.io's fly launch works.
Current behavior:
cd hello-world-enclave/
caution init
# Creates app named "app-fc8ccd2a"
Expected behavior:
cd hello-world-enclave/
caution init
# Creates app named "hello-world-enclave"
Implementation
The CLI should pass the directory name in the name field when calling POST /api/resources:
// In the init command handler
let dir_name = std::env::current_dir()
.ok()
.and_then(|p| p.file_name().map(|s| s.to_string_lossy().to_lowercase()));
let body = json!({
"cmd": build_command,
"name": dir_name // e.g., "hello-world-enclave"
});
// POST to /api/resources
API Behavior (already implemented)
The API will:
- Validate the name (3-63 chars, lowercase alphanumeric + hyphens, no consecutive hyphens, can't start/end with hyphen)
- Check uniqueness within the organization
- Fall back to app-{uuid} with a warning if:
- Name is invalid (e.g., MyApp has uppercase)
- Name is already taken
Optional Enhancement
Add a --name flag to override the directory name:
caution init --name my-custom-name
References
- API changes: platform repo,
src/api/src/main.rslines 1124-1154 - Validation rules:
src/api/src/validation.rsvalidate_app_name()
# Summary
Currently, `caution init` creates apps with auto-generated names like `app-fc8ccd2a`. We should derive the app name from the current directory name, similar to how Fly.io's `fly launch` works.
Current behavior:
```
cd hello-world-enclave/
caution init
# Creates app named "app-fc8ccd2a"
```
Expected behavior:
```
cd hello-world-enclave/
caution init
# Creates app named "hello-world-enclave"
```
# Implementation
The CLI should pass the directory name in the `name` field when calling `POST /api/resources`:
```
// In the init command handler
let dir_name = std::env::current_dir()
.ok()
.and_then(|p| p.file_name().map(|s| s.to_string_lossy().to_lowercase()));
let body = json!({
"cmd": build_command,
"name": dir_name // e.g., "hello-world-enclave"
});
// POST to /api/resources
```
# API Behavior (already implemented)
The API will:
1. Validate the name (3-63 chars, lowercase alphanumeric + hyphens, no consecutive hyphens, can't start/end with hyphen)
2. Check uniqueness within the organization
3. Fall back to app-{uuid} with a warning if:
- Name is invalid (e.g., MyApp has uppercase)
- Name is already taken
## Optional Enhancement
Add a `--name` flag to override the directory name:
`caution init --name my-custom-name`
# References
- API changes: platform repo, `src/api/src/main.rs` lines 1124-1154
- Validation rules: `src/api/src/validation.rs` `validate_app_name()`