evnx 0.2.1

A comprehensive CLI tool for managing .env files โ€” validation, secret scanning, and format conversion
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
# Contributing to evnx

Thank you for considering contributing to evnx! This document provides guidelines and instructions for contributing.

## ๐ŸŒŸ Ways to Contribute

- ๐Ÿ› Report bugs and issues
- ๐Ÿ’ก Suggest new features or improvements
- ๐Ÿ“ Improve documentation
- ๐Ÿ”ง Submit pull requests
- ๐ŸŒ Help with translations (future)
- ๐Ÿ’ฌ Answer questions in discussions
- โญ Star the repository and spread the word

## ๐Ÿ“‹ Table of Contents

- [Code of Conduct]#code-of-conduct
- [Getting Started]#getting-started
- [Development Setup]#development-setup
- [Making Changes]#making-changes
- [Submitting Changes]#submitting-changes
- [Coding Standards]#coding-standards
- [Testing Guidelines]#testing-guidelines
- [Documentation]#documentation
- [Community]#community

---

## ๐Ÿ“œ Code of Conduct

### Our Pledge

We are committed to providing a welcoming and inclusive environment for everyone, regardless of:
- Experience level
- Gender identity and expression
- Sexual orientation
- Disability
- Personal appearance
- Body size
- Race
- Ethnicity
- Age
- Religion
- Nationality

### Expected Behavior

- โœ… Be respectful and considerate
- โœ… Welcome newcomers and help them learn
- โœ… Accept constructive criticism gracefully
- โœ… Focus on what's best for the community
- โœ… Show empathy towards other community members

### Unacceptable Behavior

- โŒ Harassment, trolling, or insulting comments
- โŒ Personal or political attacks
- โŒ Publishing others' private information
- โŒ Any conduct inappropriate in a professional setting

**Enforcement:** Violations may result in temporary or permanent ban from the project.

---

## ๐Ÿš€ Getting Started

### Prerequisites

Before contributing, ensure you have:

- **Rust toolchain** (stable, 1.70+)
  ```bash
  curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  ```

- **Git**
  ```bash
  git --version
  ```

- **A GitHub account**

### First-Time Contributors

Looking for where to start? Check out:
- Issues labeled [`good first issue`]https://github.com/urwithajit9/evnx/labels/good%20first%20issue
- Issues labeled [`help wanted`]https://github.com/urwithajit9/evnx/labels/help%20wanted
- [Documentation improvements]https://github.com/urwithajit9/evnx/labels/documentation

**Don't be shy!** Everyone was a beginner once. We're here to help.

---

## ๐Ÿ› ๏ธ Development Setup

### 1. Fork and Clone

```bash
# Fork the repository on GitHub, then:
git clone https://github.com/YOUR_USERNAME/evnx.git
cd evnx

# Add upstream remote
git remote add upstream https://github.com/urwithajit9/evnx.git
```

### 2. Install Dependencies

```bash
# All dependencies are in Cargo.toml
# Just build to fetch them
cargo build
```

### 3. Verify Setup

```bash
# Run tests
cargo test

# Run clippy (linter)
cargo clippy --all-features -- -D warnings

# Format code
cargo fmt

# Build with all features
cargo build --all-features

# Run the CLI
cargo run -- --help
```

### 4. Create a Branch

```bash
# Create a new branch for your work
git checkout -b feature/your-feature-name

# Or for bug fixes
git checkout -b fix/issue-123
```

**Branch naming conventions:**
- `feature/` - New features
- `fix/` - Bug fixes
- `docs/` - Documentation changes
- `refactor/` - Code refactoring
- `test/` - Test improvements
- `chore/` - Maintenance tasks

---

## ๐Ÿ”จ Making Changes

### Code Changes

1. **Follow Rust conventions**
   - Use `cargo fmt` for formatting
   - Pass `cargo clippy` without warnings
   - Write idiomatic Rust

2. **Add tests**
   - Unit tests for individual functions
   - Integration tests for CLI commands
   - Document test purpose with comments

3. **Update documentation**
   - Update README.md if adding features
   - Add/update doc comments (`///`)
   - Update docs/ files if needed

### Documentation Changes

- Use clear, concise language
- Include examples where helpful
- Check spelling and grammar
- Test any code snippets
- Update table of contents if needed

### Example Changes

**Good commit:**
```rust
/// Validates that a variable name follows naming conventions.
///
/// # Arguments
/// * `name` - The variable name to validate
///
/// # Returns
/// * `Ok(())` if valid
/// * `Err(ValidationError)` if invalid
///
/// # Examples
/// ```
/// assert!(validate_var_name("DATABASE_URL").is_ok());
/// assert!(validate_var_name("123invalid").is_err());
/// ```
pub fn validate_var_name(name: &str) -> Result<(), ValidationError> {
    if name.is_empty() {
        return Err(ValidationError::EmptyName);
    }

    if !name.chars().next().unwrap().is_alphabetic() {
        return Err(ValidationError::InvalidStart);
    }

    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_validate_var_name() {
        assert!(validate_var_name("VALID_NAME").is_ok());
        assert!(validate_var_name("123invalid").is_err());
        assert!(validate_var_name("").is_err());
    }
}
```

---

## ๐Ÿ“ค Submitting Changes

### Before Submitting

Run the full test suite:

```bash
# Format code
cargo fmt

# Run linter
cargo clippy --all-features -- -D warnings

# Run all tests
cargo test --all-features

# Test individual features
cargo test --no-default-features
cargo test --features migrate
cargo test --features backup

# Build release to ensure it compiles
cargo build --release --all-features
```

### Commit Guidelines

Follow [Conventional Commits](https://www.conventionalcommits.org/):

```
<type>(<scope>): <subject>

<body>

<footer>
```

**Types:**
- `feat:` New feature
- `fix:` Bug fix
- `docs:` Documentation changes
- `style:` Code style changes (formatting, etc.)
- `refactor:` Code refactoring
- `test:` Adding or updating tests
- `chore:` Maintenance tasks

**Examples:**
```
feat(scan): add support for Anthropic API key detection

- Added pattern for Anthropic API keys (sk-ant-...)
- Added tests for new pattern
- Updated documentation

Closes #123
```

```
fix(validate): handle empty .env files gracefully

Previously crashed with panic on empty files.
Now returns appropriate error message.

Fixes #456
```

### Pull Request Process

1. **Update your branch**
   ```bash
   git fetch upstream
   git rebase upstream/main
   ```

2. **Push to your fork**
   ```bash
   git push origin feature/your-feature-name
   ```

3. **Create Pull Request**
   - Go to your fork on GitHub
   - Click "New Pull Request"
   - Select your branch
   - Fill out the PR template

4. **PR Description Template**
   ```markdown
   ## Description
   Brief description of changes

   ## Type of Change
   - [ ] Bug fix
   - [ ] New feature
   - [ ] Breaking change
   - [ ] Documentation update

   ## Testing
   - [ ] Unit tests added/updated
   - [ ] Integration tests added/updated
   - [ ] Manual testing performed

   ## Checklist
   - [ ] Code follows project style
   - [ ] Self-review completed
   - [ ] Comments added where needed
   - [ ] Documentation updated
   - [ ] Tests pass locally
   - [ ] No new warnings from clippy

   ## Related Issues
   Closes #123
   ```

5. **Address Review Comments**
   - Respond to all comments
   - Make requested changes
   - Push updates to the same branch
   - Re-request review

---

## ๐Ÿ“ Coding Standards

### Rust Style Guide

Follow the [Rust Style Guide](https://doc.rust-lang.org/1.0.0/style/):

```rust
// Good
fn calculate_entropy(data: &str) -> f64 {
    let bytes = data.as_bytes();
    let mut counts = HashMap::new();

    for &byte in bytes {
        *counts.entry(byte).or_insert(0) += 1;
    }

    let len = bytes.len() as f64;
    counts.values()
        .map(|&count| {
            let p = count as f64 / len;
            -p * p.log2()
        })
        .sum()
}

// Bad - inconsistent naming, unclear logic
fn calcEntropy(d: &str) -> f64 {
    let b=d.as_bytes();let mut c=HashMap::new();
    for &x in b{*c.entry(x).or_insert(0)+=1;}
    // ... (rest of implementation)
}
```

### Error Handling

Use `Result` and proper error types:

```rust
// Good
pub fn read_env_file(path: &Path) -> Result<String, EnvError> {
    fs::read_to_string(path)
        .map_err(|e| EnvError::FileRead {
            path: path.to_path_buf(),
            source: e,
        })
}

// Bad - using unwrap
pub fn read_env_file(path: &Path) -> String {
    fs::read_to_string(path).unwrap()  // โŒ Can panic!
}
```

### Documentation

Use doc comments for public items:

```rust
/// Scans a directory for accidentally committed secrets.
///
/// # Arguments
/// * `path` - Directory to scan
/// * `options` - Scan configuration options
///
/// # Returns
/// * `Ok(ScanResults)` - Found secrets and statistics
/// * `Err(ScanError)` - I/O errors or configuration issues
///
/// # Examples
/// ```
/// use evnx::scan::{scan_directory, ScanOptions};
///
/// let options = ScanOptions::default();
/// let results = scan_directory("./src", options)?;
/// println!("Found {} secrets", results.count);
/// ```
pub fn scan_directory(path: &Path, options: ScanOptions) -> Result<ScanResults, ScanError> {
    // Implementation
}
```

### Testing

Write comprehensive tests:

```rust
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_valid_env_file() {
        let content = "DATABASE_URL=postgres://localhost\nAPI_KEY=test123";
        let result = parse_env(content);
        assert!(result.is_ok());
        assert_eq!(result.unwrap().len(), 2);
    }

    #[test]
    fn test_empty_env_file() {
        let content = "";
        let result = parse_env(content);
        assert!(result.is_ok());
        assert_eq!(result.unwrap().len(), 0);
    }

    #[test]
    fn test_malformed_env_file() {
        let content = "INVALID LINE WITHOUT EQUALS";
        let result = parse_env(content);
        assert!(result.is_err());
    }
}
```

---

## ๐Ÿงช Testing Guidelines

### Running Tests

```bash
# All tests
cargo test --all-features

# Specific test
cargo test test_validate_var_name

# With output
cargo test -- --nocapture

# Integration tests only
cargo test --test integration_tests
```

### Test Coverage

We aim for:
- **80%+ code coverage** for core functionality
- **100% coverage** for security-critical code (parsing, scanning, validation)
- Integration tests for all CLI commands

### Writing Tests

1. **Unit tests** - Test individual functions
2. **Integration tests** - Test CLI commands end-to-end
3. **Property tests** - Test with random inputs (using proptest)

**Example integration test:**
```rust
#[test]
fn test_validate_command() {
    let temp_dir = tempdir().unwrap();
    let env_path = temp_dir.path().join(".env");

    fs::write(&env_path, "DATABASE_URL=postgres://localhost").unwrap();

    let output = Command::cargo_bin("evnx")
        .unwrap()
        .arg("validate")
        .arg("--strict")
        .current_dir(temp_dir.path())
        .output()
        .unwrap();

    assert!(output.status.success());
}
```

---

## ๐Ÿ“š Documentation

### What to Document

- **Public APIs** - All public functions, structs, enums
- **Examples** - Show how to use the feature
- **Edge cases** - Document unexpected behavior
- **Errors** - What errors can occur and why

### Documentation Files

- `README.md` - Overview and quick start
- `docs/GETTING_STARTED.md` - Detailed walkthrough
- `docs/USE_CASES.md` - Real-world examples
- `docs/CICD_GUIDE.md` - CI/CD integration
- `ARCHITECTURE.md` - System design
- `CHANGELOG.md` - Version history

### Updating Documentation

When adding features:
1. Update relevant docs/ files
2. Add examples to README.md
3. Update CHANGELOG.md (unreleased section)
4. Add doc comments to code

---

## ๐Ÿค Community

### Getting Help

- ๐Ÿ’ฌ [GitHub Discussions]https://github.com/urwithajit9/evnx/discussions - Ask questions
- ๐Ÿ› [Issue Tracker]https://github.com/urwithajit9/evnx/issues - Report bugs
- ๐Ÿ“ง Email: support@dotenv.space

### Communication Channels

- **GitHub Discussions** - Questions, ideas, show & tell
- **Issue Tracker** - Bug reports, feature requests
- **Pull Requests** - Code review and discussion

### Response Times

We try to:
- Respond to issues within 48 hours
- Review PRs within 1 week
- Cut releases monthly (or as needed for security)

---

## ๐ŸŽฏ Development Priorities

### High Priority
- Security improvements (secret detection patterns)
- Performance optimization
- Windows support improvements
- Documentation

### Medium Priority
- New format converters
- Additional secret patterns
- CLI UX improvements
- Integration examples

### Low Priority
- Translations (i18n)
- GUI wrapper
- Web service version
- Plugins/extensions

---

## ๐Ÿ† Recognition

Contributors are recognized in:
- `CONTRIBUTORS.md` file
- Release notes
- GitHub contributors graph

Significant contributions may be highlighted in:
- Blog posts
- Social media
- Project website

---

## ๐Ÿ“ License

By contributing, you agree that your contributions will be licensed under the MIT License.

---

## โ“ Questions?

Don't hesitate to ask! There are no stupid questions.

- Open a [Discussion]https://github.com/urwithajit9/evnx/discussions
- Comment on an existing issue
- Email: support@dotenv.space

**Thank you for making evnx better!** ๐Ÿ™

---

<div align="center">

**Made with ๐Ÿฆ€ Rust and โค๏ธ by contributors like you**

[Website](https://dotenv.space) โ€ข [Documentation](./docs/GETTING_STARTED.md) โ€ข [GitHub](https://github.com/urwithajit9/evnx)

</div>