forked from micronaut-projects/micronaut-acme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Would have used @mixin (see https://picocli.info/apidocs/picocli/CommandLine.Mixin.html), but I think I ran into issues with remkop/picocli#450 (or a similar issue) where the mutually exclusive argument group was ignored when 'AcmeServerOption` was imported as a Mixin (vs directly using '@Arggroup(multiplicity = "1")' where it was used.
- Loading branch information
Showing
3 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
acme-cli/src/main/java/io/micronaut/acme/cli/AcmeServerOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.micronaut.acme.cli; | ||
|
||
import picocli.CommandLine; | ||
|
||
public class AcmeServerOption { | ||
|
||
public static final String LE_PROD_URL = "https://acme-v02.api.letsencrypt.org/directory"; | ||
|
||
public static final String LE_STAGING_URL = "https://acme-staging-v02.api.letsencrypt.org/directory"; | ||
|
||
@CommandLine.Option(names = {"-u", "--url"}, required = true, showDefaultValue = CommandLine.Help.Visibility.ALWAYS, description = "Location of acme server to use.%nLet's Encrypt Prod :%n@|bold " + LE_PROD_URL + "|@%nLet's Encrypt Staging :%n@|bold " + LE_STAGING_URL + "|@") | ||
private String serverUrl; | ||
|
||
@CommandLine.Option(names = {"--lets-encrypt-prod"}, required = true, description = "Use the Let's Encrypt prod URL") | ||
private boolean letsEncryptProd; | ||
|
||
@CommandLine.Option(names = {"--lets-encrypt-staging"}, required = true, description = "Use the Let's Encrypt prod URL") | ||
private boolean letsEncryptStaging; | ||
|
||
|
||
public String serverUrl() { | ||
if (letsEncryptProd) { | ||
return LE_PROD_URL; | ||
} | ||
if (letsEncryptStaging) { | ||
return LE_STAGING_URL; | ||
} | ||
return serverUrl; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters