-
Notifications
You must be signed in to change notification settings - Fork 5k
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
CAMEL-21896: camel-jbang - Allow configuration preset per directory #17593
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,9 @@ public class ConfigUnset extends CamelCommand { | |
@CommandLine.Parameters(description = "Configuration key", arity = "1") | ||
String key; | ||
|
||
@CommandLine.Option(names = { "--local" }, description = "Retrieve configurations from current directory") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Unset" instead of "Retrieve" |
||
boolean local; | ||
|
||
public ConfigUnset(CamelJBangMain main) { | ||
super(main); | ||
} | ||
|
@@ -36,8 +39,8 @@ public ConfigUnset(CamelJBangMain main) { | |
public Integer doCall() throws Exception { | ||
CommandLineHelper.loadProperties(properties -> { | ||
properties.remove(key); | ||
CommandLineHelper.storeProperties(properties, printer()); | ||
}); | ||
CommandLineHelper.storeProperties(properties, printer(), local); | ||
}, local); | ||
|
||
return 0; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,13 +43,16 @@ public class VersionSet extends CamelCommand { | |
@CommandLine.Option(names = { "--reset" }, description = "Reset by removing any custom version settings") | ||
boolean reset; | ||
|
||
@CommandLine.Option(names = { "--local" }, description = "Retrieve configurations from current directory") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Store ... to" over "Retrieve ... from" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or if we want the same wording for all options, we should consider a more generic wording. Examples: |
||
boolean local; | ||
|
||
public VersionSet(CamelJBangMain main) { | ||
super(main); | ||
} | ||
|
||
@Override | ||
public Integer doCall() throws Exception { | ||
CommandLineHelper.createPropertyFile(); | ||
CommandLineHelper.createPropertyFile(local); | ||
|
||
CommandLineHelper.loadProperties(properties -> { | ||
if (reset) { | ||
|
@@ -67,8 +70,8 @@ public Integer doCall() throws Exception { | |
properties.put("runtime", runtime.runtime()); | ||
} | ||
} | ||
CommandLineHelper.storeProperties(properties, printer()); | ||
}); | ||
CommandLineHelper.storeProperties(properties, printer(), local); | ||
}, local); | ||
|
||
return 0; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.dsl.jbang.core.commands.config; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import org.apache.camel.dsl.jbang.core.commands.CamelCommandBaseTest; | ||
import org.apache.camel.dsl.jbang.core.common.CommandLineHelper; | ||
import org.junit.jupiter.api.AfterEach; | ||
|
||
public class BaseConfigTest extends CamelCommandBaseTest { | ||
|
||
@AfterEach | ||
void removeLocalConfigFile() throws IOException { | ||
Files.deleteIfExists(Paths.get(CommandLineHelper.USER_CONFIG)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wording should be "Store ... to" instead of "Retrieve ... from" here.