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
//! Controller for refreshing the current project configuration.
//!
//! When a user runs the `prustio refresh` command, this module reads the
//! currently active environment from `Prustio.toml` and re-applies its
//! configuration across the project. This is particularly useful if configuration
//! files have been manually edited or if the project state needs to be resynchronized.
use env;
use cratectr_activate;
use crateprustio_config;
use crateutils;
/// Refreshes the project by re-activating the current environment.
///
/// This function locates the current pRustIO project, determines the currently
/// active environment from the package metadata, and internally calls the
/// `activate` controller to refresh the `Cargo.toml` and `.cargo/config.toml` files.
///
/// # Arguments
/// * `json_output` - If `true`, suppresses standard console logs for JSON compatibility
/// (this flag is passed down to the `activate_environment` call).
///
/// # Errors
/// Returns an error string if:
/// * The current working directory cannot be determined.
/// * The current directory is not a valid pRustIO project (missing `Prustio.toml`).
/// * The `Prustio.toml` configuration cannot be read or parsed.
/// * There is no currently active environment set for the project.