Skip to content

Commit a22229c

Browse files
authored
Merge pull request #139 from AbelOsaretin/fix/issues-92-93-95-98
fix: resolve issues #92, #93, #95, #98 - duplicate Template removal, wallet export/import, and completions sync
2 parents 0d24492 + b6282ad commit a22229c

8 files changed

Lines changed: 492 additions & 122 deletions

File tree

API_REFERENCE.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,50 @@ starforge wallet rename alice alice-testnet
222222

223223
---
224224

225+
### `starforge wallet export`
226+
227+
Export a wallet to a JSON backup file.
228+
229+
**Usage:**
230+
```bash
231+
starforge wallet export <NAME> --output <FILE>
232+
```
233+
234+
**Arguments:**
235+
- `<NAME>` - Wallet name to export
236+
237+
**Options:**
238+
- `--output <FILE>` - Output file path for the backup JSON
239+
240+
**Example:**
241+
```bash
242+
starforge wallet export alice --output ./wallet-backup.json
243+
```
244+
245+
**Notes:**
246+
- Secrets are written only to the backup file and are never printed to stdout.
247+
248+
---
249+
250+
### `starforge wallet import`
251+
252+
Import wallets from a JSON backup file.
253+
254+
**Usage:**
255+
```bash
256+
starforge wallet import --file <FILE>
257+
```
258+
259+
**Options:**
260+
- `--file <FILE>` - Path to a wallet backup JSON file
261+
262+
**Example:**
263+
```bash
264+
starforge wallet import --file ./wallet-backup.json
265+
```
266+
267+
---
268+
225269
### `starforge wallet sign`
226270

227271
Sign an arbitrary message using a wallet.

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DEVELOPER_GUIDE.md

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ RUST_LOG=debug cargo run -- wallet list
5555
#### VS Code
5656

5757
Recommended extensions:
58+
5859
- `rust-analyzer` - Rust language support
5960
- `crates` - Cargo.toml dependency management
6061
- `Better TOML` - TOML syntax highlighting
6162
- `Error Lens` - Inline error display
6263

6364
`.vscode/settings.json`:
65+
6466
```json
6567
{
6668
"rust-analyzer.checkOnSave.command": "clippy",
@@ -72,6 +74,7 @@ Recommended extensions:
7274
#### IntelliJ IDEA / CLion
7375

7476
Install the Rust plugin and configure:
77+
7578
- Enable Clippy for code analysis
7679
- Set rustfmt as formatter
7780
- Enable external linter
@@ -175,7 +178,7 @@ fn private_helper() { /* ... */ }
175178
#[cfg(test)]
176179
mod tests {
177180
use super::*;
178-
181+
179182
#[test]
180183
fn test_something() { /* ... */ }
181184
}
@@ -207,13 +210,13 @@ pub fn CreateWallet(Name: String, Encrypt: bool) -> Result<()> {
207210

208211
### Naming Conventions
209212

210-
| Type | Convention | Example |
211-
|------|------------|---------|
212-
| Functions | `snake_case` | `fetch_account()` |
213-
| Types | `PascalCase` | `WalletEntry` |
214-
| Constants | `SCREAMING_SNAKE_CASE` | `MAX_RETRIES` |
215-
| Modules | `snake_case` | `hardware_wallet` |
216-
| Lifetimes | `'lowercase` | `'a`, `'static` |
213+
| Type | Convention | Example |
214+
| --------- | ---------------------- | ----------------- |
215+
| Functions | `snake_case` | `fetch_account()` |
216+
| Types | `PascalCase` | `WalletEntry` |
217+
| Constants | `SCREAMING_SNAKE_CASE` | `MAX_RETRIES` |
218+
| Modules | `snake_case` | `hardware_wallet` |
219+
| Lifetimes | `'lowercase` | `'a`, `'static` |
217220

218221
### Error Handling
219222

@@ -239,7 +242,7 @@ let data = load_data()
239242

240243
### Documentation
241244

242-
```rust
245+
````rust
243246
/// Fetches account information from Horizon API.
244247
///
245248
/// # Arguments
@@ -267,7 +270,7 @@ let data = load_data()
267270
pub fn fetch_account(public_key: &str, network: &str) -> Result<AccountResponse> {
268271
// Implementation
269272
}
270-
```
273+
````
271274

272275
### Comments
273276

@@ -326,17 +329,17 @@ pub fn handle(cmd: MyCommands) -> Result<()> {
326329
fn action(input: String) -> Result<()> {
327330
p::header("My Command");
328331
p::kv("Input", &input);
329-
332+
330333
// Your logic here
331-
334+
332335
p::success("Done!");
333336
Ok(())
334337
}
335338

336339
#[cfg(test)]
337340
mod tests {
338341
use super::*;
339-
342+
340343
#[test]
341344
fn test_action() {
342345
// Test your command
@@ -358,7 +361,7 @@ pub mod mycommand;
358361
#[derive(Subcommand)]
359362
enum Commands {
360363
// ... existing commands
361-
364+
362365
/// My new command
363366
#[command(subcommand)]
364367
MyCommand(commands::mycommand::MyCommands),
@@ -402,7 +405,7 @@ pub fn do_something(input: &str) -> Result<String> {
402405
#[cfg(test)]
403406
mod tests {
404407
use super::*;
405-
408+
406409
#[test]
407410
fn test_do_something() {
408411
let result = do_something("test").unwrap();
@@ -502,20 +505,20 @@ impl {{PROJECT_NAME_PASCAL}} {
502505
#[cfg(test)]
503506
mod tests {
504507
use super::*;
505-
508+
506509
#[test]
507510
fn test_basic_functionality() {
508511
let result = my_function("input");
509512
assert!(result.is_ok());
510513
assert_eq!(result.unwrap(), "expected");
511514
}
512-
515+
513516
#[test]
514517
fn test_error_case() {
515518
let result = my_function("");
516519
assert!(result.is_err());
517520
}
518-
521+
519522
#[test]
520523
#[should_panic(expected = "Invalid input")]
521524
fn test_panic() {
@@ -535,11 +538,11 @@ use tempfile::TempDir;
535538
fn test_config_lifecycle() {
536539
let temp = TempDir::new().unwrap();
537540
let config_path = temp.path().join("config.toml");
538-
541+
539542
// Test save
540543
let config = config::Config::default();
541544
config::save(&config).unwrap();
542-
545+
543546
// Test load
544547
let loaded = config::load().unwrap();
545548
assert_eq!(loaded.version, config.version);
@@ -686,6 +689,15 @@ cargo fmt --check
686689
rustfmt src/main.rs
687690
```
688691

692+
### Regenerating Shell Completions
693+
694+
Shell completion scripts are generated by `build.rs` into the `completions/` directory.
695+
696+
```bash
697+
# Regenerate completions (bash/zsh/fish)
698+
cargo build
699+
```
700+
689701
### Building Documentation
690702

691703
```bash
@@ -778,19 +790,22 @@ rust-gdb target/debug/starforge
778790
### Common Issues
779791

780792
**Issue**: Compilation errors after updating dependencies
793+
781794
```bash
782795
# Solution: Clean and rebuild
783796
cargo clean
784797
cargo build
785798
```
786799

787800
**Issue**: Tests failing intermittently
801+
788802
```bash
789803
# Solution: Run tests serially
790804
cargo test -- --test-threads=1
791805
```
792806

793807
**Issue**: Slow compilation
808+
794809
```bash
795810
# Solution: Use sccache
796811
cargo install sccache
@@ -948,6 +963,7 @@ fn creates_wallet_with_encrypted_key_when_encrypt_flag_is_true() {
948963
```
949964

950965
Types:
966+
951967
- `feat`: New feature
952968
- `fix`: Bug fix
953969
- `docs`: Documentation
@@ -957,6 +973,7 @@ Types:
957973
- `chore`: Maintenance
958974

959975
Examples:
976+
960977
```
961978
feat(wallet): add hardware wallet support
962979
@@ -970,18 +987,21 @@ Closes #123
970987
## Resources
971988

972989
### Documentation
990+
973991
- [Rust Book](https://doc.rust-lang.org/book/)
974992
- [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/)
975993
- [Stellar Documentation](https://developers.stellar.org/)
976994
- [Soroban Documentation](https://soroban.stellar.org/)
977995

978996
### Tools
997+
979998
- [rust-analyzer](https://rust-analyzer.github.io/) - IDE support
980999
- [clippy](https://github.com/rust-lang/rust-clippy) - Linter
9811000
- [rustfmt](https://github.com/rust-lang/rustfmt) - Formatter
9821001
- [cargo-edit](https://github.com/killercup/cargo-edit) - Dependency management
9831002

9841003
### Community
1004+
9851005
- [Stellar Discord](https://discord.gg/stellar)
9861006
- [Rust Users Forum](https://users.rust-lang.org/)
9871007
- [GitHub Discussions](https://github.com/YOUR_USERNAME/starforge/discussions)

build.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,23 @@ enum Commands {
1616
Wallet,
1717
New,
1818
Contract,
19+
Inspect,
1920
Deploy,
2021
Info,
2122
Tx,
2223
Network,
2324
Completions,
25+
Shell,
26+
Monitor,
27+
Tutorial,
28+
Benchmark,
29+
Test,
30+
Gas,
31+
Plugin,
32+
Template,
33+
Upgrade,
34+
#[command(external_subcommand)]
35+
External(Vec<String>),
2436
}
2537

2638
fn main() {
@@ -30,7 +42,7 @@ fn main() {
3042
};
3143

3244
let mut cmd = Cli::command();
33-
45+
3446
// Create a directory for completions in the project root for easier access
3547
// or just leave them in OUT_DIR as per standard practice.
3648
// The issue says "Install completions to appropriate system directories".
@@ -40,7 +52,8 @@ fn main() {
4052
fs::create_dir_all(&completions_dir).unwrap();
4153

4254
for &shell in &[Shell::Bash, Shell::Zsh, Shell::Fish] {
43-
generate_to(shell, &mut cmd, "starforge", &completions_dir).expect("Failed to generate completions");
55+
generate_to(shell, &mut cmd, "starforge", &completions_dir)
56+
.expect("Failed to generate completions");
4457
}
4558

4659
let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());

src/commands/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod benchmark;
12
pub mod completions;
23
pub mod contract;
34
pub mod deploy;
@@ -9,12 +10,10 @@ pub mod monitor;
910
pub mod network;
1011
pub mod new;
1112
pub mod plugin;
12-
pub mod template;
1313
pub mod shell;
1414
pub mod template;
1515
pub mod test;
16-
pub mod tx;
17-
pub mod wallet;
1816
pub mod tutorial;
19-
pub mod benchmark;
17+
pub mod tx;
2018
pub mod upgrade;
19+
pub mod wallet;

0 commit comments

Comments
 (0)