Skip to content

Incorporating Environment Variables? #402

Answered by patriksvensson
phantlantis asked this question in Q&A
Discussion options

You must be logged in to vote

Since you do not require the Platform parameter to be passed via the command line, it must be optional.

In this case, you can add custom validation that assigns the environment variable if Platform is not set or returns a validation error if neither is set.

public class CreateTicketSettings : CommandSettings
{
    [Description("Platform to create request for (web, ios, android)")]
    [CommandArgument(0, "[platform]")]
    public string Platform { get; set; }

    public override ValidationResult Validate()
    {
        // No platform provided?
        if (Platform == null)
        {
            // Use the one defined in the environment variable.
            var platformEV = System.Envir…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@phantlantis
Comment options

Comment options

You must be logged in to vote
1 reply
@phantlantis
Comment options

Answer selected by phantlantis
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants