Support Windows default location for config file.
This commit is contained in:
parent
1bbe713fc2
commit
2c84a2478e
|
@ -2,7 +2,12 @@
|
|||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [1.3.0] - 2022-02-xx
|
||||
## [1.3.1] - 2022-04-xx
|
||||
### Added
|
||||
- Default configuration location on Windows platform.
|
||||
|
||||
|
||||
## [1.3.0] - 2022-02-04
|
||||
### Changed
|
||||
- Correct use of InfluxDB batch writing.
|
||||
|
||||
|
@ -16,6 +21,7 @@ All notable changes to this project will be documented in this file.
|
|||
### Added
|
||||
- Options to include/exclude Managed Systems and/or Logical Partitions.
|
||||
|
||||
[1.3.1]: https://bitbucket.org/mnellemann/hmci/branches/compare/v1.3.1%0Dv1.3.0
|
||||
[1.3.0]: https://bitbucket.org/mnellemann/hmci/branches/compare/v1.3.0%0Dv1.2.8
|
||||
[1.2.8]: https://bitbucket.org/mnellemann/hmci/branches/compare/v1.2.8%0Dv1.2.7
|
||||
[1.2.7]: https://bitbucket.org/mnellemann/hmci/branches/compare/v1.2.7%0Dv1.2.6
|
||||
|
|
|
@ -22,7 +22,7 @@ sourceCompatibility = projectJavaVersion
|
|||
targetCompatibility = projectJavaVersion
|
||||
|
||||
dependencies {
|
||||
annotationProcessor 'info.picocli:picocli-codegen:4.6.2'
|
||||
annotationProcessor 'info.picocli:picocli-codegen:4.6.3'
|
||||
implementation 'info.picocli:picocli:4.6.3'
|
||||
implementation 'org.jsoup:jsoup:1.14.3'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
projectId = hmci
|
||||
projectGroup = biz.nellemann.hmci
|
||||
projectVersion = 1.3.0
|
||||
projectVersion = 1.3.1
|
||||
projectJavaVersion = 1.8
|
||||
|
|
|
@ -28,13 +28,14 @@ import java.util.concurrent.Callable;
|
|||
|
||||
@Command(name = "hmci",
|
||||
mixinStandardHelpOptions = true,
|
||||
versionProvider = biz.nellemann.hmci.VersionProvider.class)
|
||||
versionProvider = biz.nellemann.hmci.VersionProvider.class,
|
||||
defaultValueProvider = biz.nellemann.hmci.DefaultProvider.class)
|
||||
public class Application implements Callable<Integer> {
|
||||
|
||||
@Option(names = { "-c", "--conf" }, description = "Configuration file [default: '/etc/hmci.toml'].", defaultValue = "/etc/hmci.toml", paramLabel = "<file>")
|
||||
@Option(names = { "-c", "--conf" }, description = "Configuration file [default: ${DEFAULT-VALUE}].", paramLabel = "<file>")
|
||||
private File configurationFile;
|
||||
|
||||
@Option(names = { "-d", "--debug" }, description = "Enable debugging [default: 'false'].")
|
||||
@Option(names = { "-d", "--debug" }, description = "Enable debugging [default: false].")
|
||||
private boolean[] enableDebug = new boolean[0];
|
||||
|
||||
|
||||
|
|
33
src/main/java/biz/nellemann/hmci/DefaultProvider.java
Normal file
33
src/main/java/biz/nellemann/hmci/DefaultProvider.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package biz.nellemann.hmci;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
public class DefaultProvider implements CommandLine.IDefaultValueProvider {
|
||||
|
||||
public String defaultValue(CommandLine.Model.ArgSpec argSpec) throws Exception {
|
||||
if(argSpec.isOption()) {
|
||||
switch (argSpec.paramLabel()) {
|
||||
case "<file>":
|
||||
return getDefaultConfigFileLocation();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isWindowsOperatingSystem() {
|
||||
String os = System.getProperty("os.name");
|
||||
return os.toLowerCase().startsWith("windows");
|
||||
}
|
||||
|
||||
private String getDefaultConfigFileLocation() {
|
||||
String configFilePath;
|
||||
if(isWindowsOperatingSystem()) {
|
||||
configFilePath = System.getProperty("user.home") + "\\hmci.toml";
|
||||
} else {
|
||||
configFilePath = "/etc/hmci.toml";
|
||||
}
|
||||
return configFilePath;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue