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

Make config location editable via option #43

Open
wants to merge 2 commits into
base: 3.5
Choose a base branch
from

Conversation

maartenvr98
Copy link

This makes it posible to define an alternative location for your config file. For example you want it inside a config folder or outside your project root.

Simply define the env variable CRUNZ_CONFIG in your environment or export before executing the command:
ie: export CRUNZ_CONFIG=config/crunz.yml && php vendor/bin/crunz

Q A
Fixed tickets #...

This makes it posible to define an alternative location for your config file. For example you want it inside a config folder or outside your project root. 

Simply define the env variable CRUNZ_CONFIG in your environment or export before executing the command:
ie: export CRUNZ_CONFIG=config/crunz.yml && php vendor/bin/crunz
@PabloKowalczyk
Copy link
Member

Hello, I like the idea but would like to see it as --config option, also remember about tests.

@maartenvr98
Copy link
Author

@PabloKowalczyk I've updated my PR. Config setting is now available via --config.

The only problem was that the configuration was already used in the commands configure. So I had to parse the option before the commands init, thats why it already checks for --config in the Application constructor.

@maartenvr98 maartenvr98 changed the title Make config file name editable via env variable Make config location editable via option Nov 7, 2022
@PabloKowalczyk
Copy link
Member

There are some issues in CI https://github.com/crunzphp/crunz/actions/runs/3411655638/jobs/5743651750, also please revert "style" changes.

@@ -15,7 +15,7 @@

final class ConfigGeneratorCommand extends Command
{
public const CONFIG_FILE_NAME = 'crunz.yml';
public static string $CONFIG_FILE_NAME = 'crunz.yml';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be better to leave that constant as is and create new parameter in container.


$configFileName = ConfigGeneratorCommand::$CONFIG_FILE_NAME;

$configPath = Path::fromStrings($cwd ?? '', $configFileName)->toString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to provide absolute path?


$this->add($command);
}
}

public function run(InputInterface $input = null, OutputInterface $output = null): int
{
// Add config option to all commands
$this->getDefinition()->addOptions([
new InputOption(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing tests for new --config option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants