Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a PYAPP_EXPOSE_ALL_COMMANDS environment variable to expose all the management commands by default #134

Merged
merged 6 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ passthrough = [
"PYAPP_EXEC_NOTEBOOK",
"PYAPP_EXEC_SCRIPT",
"PYAPP_EXEC_SPEC",
"PYAPP_EXPOSE_ALL_COMMANDS",
"PYAPP_EXPOSE_CACHE",
"PYAPP_EXPOSE_METADATA",
"PYAPP_EXPOSE_PIP",
Expand Down
8 changes: 7 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ fn is_enabled(name: &str) -> bool {
["true", "1"].contains(&env::var(name).unwrap_or_default().as_str())
}

fn is_explicitly_disabled(name: &str) -> bool {
["false", "0"].contains(&env::var(name).unwrap_or_default().as_str())
}

fn normalize_project_name(name: &String) -> String {
// https://peps.python.org/pep-0508/#names
if !Regex::new(r"^([[:alnum:]]|[[:alnum:]][[:alnum:]._-]*[[:alnum:]])$")
Expand Down Expand Up @@ -1001,7 +1005,9 @@ fn set_exposed_command(path: &Path, command_name: &str, indicator: &Regex) {
let command_source = fs::read_to_string(command_path).unwrap();
if indicator.is_match(&command_source) {
let variable = format!("PYAPP_EXPOSE_{}", command_name.to_uppercase());
if is_enabled(&variable) {
if is_enabled(&variable)
|| (!is_explicitly_disabled(&variable) && is_enabled("PYAPP_EXPOSE_ALL_COMMANDS"))
ofek marked this conversation as resolved.
Show resolved Hide resolved
{
set_runtime_variable(&variable, "1");
} else {
set_runtime_variable(&variable, "0");
Expand Down
2 changes: 1 addition & 1 deletion docs/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ This will update the project to the latest available version in the currently us

### Optional

These commands are hidden by default and each can be individually exposed by setting its corresponding `PYAPP_EXPOSE_<COMMAND>` option (e.g. `PYAPP_EXPOSE_METADATA`) to `true` or `1`.
These commands are hidden by default and each can be individually exposed by setting its corresponding `PYAPP_EXPOSE_<COMMAND>` option (e.g. `PYAPP_EXPOSE_METADATA`) to `true` or `1`. You can enable all of them at once setting the `PYAPP_EXPOSE_ALL_COMMANDS` option to `true` or `1`.
ofek marked this conversation as resolved.
Show resolved Hide resolved

#### Cache

Expand Down