settingspec 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {settingspec-0.4.0 → settingspec-0.5.0}/Cargo.lock +1 -1
  2. {settingspec-0.4.0 → settingspec-0.5.0}/Cargo.toml +1 -1
  3. {settingspec-0.4.0 → settingspec-0.5.0}/PKG-INFO +9 -3
  4. {settingspec-0.4.0 → settingspec-0.5.0}/README.md +8 -2
  5. {settingspec-0.4.0 → settingspec-0.5.0}/src/cli.rs +47 -2
  6. {settingspec-0.4.0 → settingspec-0.5.0}/LICENSE-APACHE +0 -0
  7. {settingspec-0.4.0 → settingspec-0.5.0}/LICENSE-MIT +0 -0
  8. {settingspec-0.4.0 → settingspec-0.5.0}/pyproject.toml +0 -0
  9. {settingspec-0.4.0 → settingspec-0.5.0}/src/envfile.rs +0 -0
  10. {settingspec-0.4.0 → settingspec-0.5.0}/src/error.rs +0 -0
  11. {settingspec-0.4.0 → settingspec-0.5.0}/src/filter.rs +0 -0
  12. {settingspec-0.4.0 → settingspec-0.5.0}/src/generator/common.rs +0 -0
  13. {settingspec-0.4.0 → settingspec-0.5.0}/src/generator/env.rs +0 -0
  14. {settingspec-0.4.0 → settingspec-0.5.0}/src/generator/javascript.rs +0 -0
  15. {settingspec-0.4.0 → settingspec-0.5.0}/src/generator/json.rs +0 -0
  16. {settingspec-0.4.0 → settingspec-0.5.0}/src/generator/lua.rs +0 -0
  17. {settingspec-0.4.0 → settingspec-0.5.0}/src/generator/mod.rs +0 -0
  18. {settingspec-0.4.0 → settingspec-0.5.0}/src/generator/python.rs +0 -0
  19. {settingspec-0.4.0 → settingspec-0.5.0}/src/generator/toml.rs +0 -0
  20. {settingspec-0.4.0 → settingspec-0.5.0}/src/generator/tree.rs +0 -0
  21. {settingspec-0.4.0 → settingspec-0.5.0}/src/generator/typescript.rs +0 -0
  22. {settingspec-0.4.0 → settingspec-0.5.0}/src/generator/yaml.rs +0 -0
  23. {settingspec-0.4.0 → settingspec-0.5.0}/src/lib.rs +0 -0
  24. {settingspec-0.4.0 → settingspec-0.5.0}/src/main.rs +0 -0
  25. {settingspec-0.4.0 → settingspec-0.5.0}/src/model.rs +0 -0
  26. {settingspec-0.4.0 → settingspec-0.5.0}/src/parser.rs +0 -0
  27. {settingspec-0.4.0 → settingspec-0.5.0}/src/profile.rs +0 -0
  28. {settingspec-0.4.0 → settingspec-0.5.0}/src/resolver.rs +0 -0
@@ -1758,7 +1758,7 @@ dependencies = [
1758
1758
 
1759
1759
  [[package]]
1760
1760
  name = "settingspec"
1761
- version = "0.4.0"
1761
+ version = "0.5.0"
1762
1762
  dependencies = [
1763
1763
  "age",
1764
1764
  "anyhow",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "settingspec"
3
- version = "0.4.0"
3
+ version = "0.5.0"
4
4
  edition = "2024"
5
5
  description = "One file for all environments, all languages, all submodules."
6
6
  readme = "README.md"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: settingspec
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -19,7 +19,7 @@ Project-URL: Source Code, https://github.com/sayanarijit/settingspec
19
19
  <picture>
20
20
  <source media="(prefers-color-scheme: dark)" srcset="https://s15.gifyu.com/images/buXVO.png">
21
21
  <source media="(prefers-color-scheme: light)" srcset="https://s15.gifyu.com/images/buXZJ.png">
22
- <img alt="The settingspec cover" width="600" src="https://s15.gifyu.com/images/buXZJ.png">
22
+ <img alt="The settingspec cover" width="100%" src="https://s15.gifyu.com/images/buXZJ.png">
23
23
  </picture>
24
24
  </p>
25
25
 
@@ -28,7 +28,7 @@ Project-URL: Source Code, https://github.com/sayanarijit/settingspec
28
28
  [![PyPI Version](https://img.shields.io/pypi/v/settingspec)](https://pypi.org/project/settingspec)
29
29
  [![NPM Version](https://img.shields.io/npm/v/%40sayanarijit%2Fsettingspec)](https://www.npmjs.com/package/@sayanarijit/settingspec)
30
30
 
31
- # Table of contents
31
+ # SettingSpec
32
32
 
33
33
  1. [Concepts](#concepts)
34
34
  1. [Single file convenience](#single-file-convenience)
@@ -109,6 +109,12 @@ Now export the final settings as declared.
109
109
  settingspec export
110
110
  ```
111
111
 
112
+ Or keep watching to export when `settingspec.toml` changes.
113
+
114
+ ```bash
115
+ settingspec watch
116
+ ```
117
+
112
118
  Or directly run the program with exported settings.
113
119
 
114
120
  ```bash
@@ -2,7 +2,7 @@
2
2
  <picture>
3
3
  <source media="(prefers-color-scheme: dark)" srcset="https://s15.gifyu.com/images/buXVO.png">
4
4
  <source media="(prefers-color-scheme: light)" srcset="https://s15.gifyu.com/images/buXZJ.png">
5
- <img alt="The settingspec cover" width="600" src="https://s15.gifyu.com/images/buXZJ.png">
5
+ <img alt="The settingspec cover" width="100%" src="https://s15.gifyu.com/images/buXZJ.png">
6
6
  </picture>
7
7
  </p>
8
8
 
@@ -11,7 +11,7 @@
11
11
  [![PyPI Version](https://img.shields.io/pypi/v/settingspec)](https://pypi.org/project/settingspec)
12
12
  [![NPM Version](https://img.shields.io/npm/v/%40sayanarijit%2Fsettingspec)](https://www.npmjs.com/package/@sayanarijit/settingspec)
13
13
 
14
- # Table of contents
14
+ # SettingSpec
15
15
 
16
16
  1. [Concepts](#concepts)
17
17
  1. [Single file convenience](#single-file-convenience)
@@ -92,6 +92,12 @@ Now export the final settings as declared.
92
92
  settingspec export
93
93
  ```
94
94
 
95
+ Or keep watching to export when `settingspec.toml` changes.
96
+
97
+ ```bash
98
+ settingspec watch
99
+ ```
100
+
95
101
  Or directly run the program with exported settings.
96
102
 
97
103
  ```bash
@@ -8,7 +8,10 @@ use crate::profile::resolve_active_profile;
8
8
  use crate::resolver::resolve_settings;
9
9
  use clap::{Parser, Subcommand};
10
10
  use std::collections::HashMap;
11
+ use std::io::Write;
11
12
  use std::path::{Path, PathBuf};
13
+ use std::sync::mpsc;
14
+ use std::time::Duration;
12
15
 
13
16
  #[derive(Parser, Debug)]
14
17
  #[command(
@@ -34,6 +37,8 @@ pub enum Commands {
34
37
  #[arg(last = true, required = true)]
35
38
  command: Vec<String>,
36
39
  },
40
+ /// Watches settingspec.toml and regenerates exports whenever it changes
41
+ Watch,
37
42
  }
38
43
 
39
44
  pub const INIT_CONFIG: &str = r#"[spec]
@@ -145,9 +150,51 @@ pub fn run_cli() -> Result<()> {
145
150
  let ctx = load_and_resolve()?;
146
151
  execute_run(&ctx, &command)
147
152
  }
153
+ Commands::Watch => run_watch(),
148
154
  }
149
155
  }
150
156
 
157
+ fn run_watch() -> Result<()> {
158
+ let ctx = load_and_resolve()?;
159
+ perform_export(&ctx)?;
160
+
161
+ let config_path = ctx.project_root.join("settingspec.toml");
162
+
163
+ let (tx, rx) = mpsc::channel();
164
+
165
+ std::thread::spawn(move || {
166
+ let mut modified = std::fs::metadata(&config_path)
167
+ .ok()
168
+ .and_then(|m| m.modified().ok());
169
+ loop {
170
+ std::thread::sleep(Duration::from_secs(1));
171
+ let new_modified = std::fs::metadata(&config_path)
172
+ .ok()
173
+ .and_then(|m| m.modified().ok());
174
+ if new_modified != modified {
175
+ modified = new_modified;
176
+ let _ = tx.send(());
177
+ }
178
+ }
179
+ });
180
+
181
+ while rx.recv().is_ok() {
182
+ println!("Detected change in settingspec.toml, reloading...");
183
+ match load_and_resolve() {
184
+ Ok(ctx) => {
185
+ if let Err(e) = perform_export(&ctx) {
186
+ eprintln!("Error during export: {}", e);
187
+ }
188
+ }
189
+ Err(e) => {
190
+ eprintln!("Error loading configuration: {}", e);
191
+ }
192
+ }
193
+ }
194
+
195
+ Ok(())
196
+ }
197
+
151
198
  fn perform_export(ctx: &ExecutionContext) -> Result<Vec<PathBuf>> {
152
199
  auto_append_gitignore(ctx)?;
153
200
 
@@ -250,7 +297,6 @@ fn execute_run(ctx: &ExecutionContext, command_args: &[String]) -> Result<()> {
250
297
  let child_stdin = child.stdin.take();
251
298
  let writer = std::thread::spawn(move || {
252
299
  if let Some(mut stdin) = child_stdin {
253
- use std::io::Write;
254
300
  let _ = stdin.write_all(payload.as_bytes());
255
301
  }
256
302
  });
@@ -449,7 +495,6 @@ pub fn auto_append_gitignore(ctx: &ExecutionContext) -> Result<()> {
449
495
  to_append.push('\n');
450
496
  }
451
497
 
452
- use std::io::Write;
453
498
  let mut file = std::fs::OpenOptions::new()
454
499
  .create(true)
455
500
  .append(true)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes