Nebula
Core

CommandLine

Tiny "-key value" / "-key=value" / "-flag" parser over Environment.GetCommandLineArgs.

generated from the sources
Static class in namespace Nebula · Packages/com.1by3.nebula/Runtime/Core/CommandLine.cs
public static class CommandLine

Tiny "-key value" / "-key=value" / "-flag" parser over Environment.GetCommandLineArgs. A web build has no command line and reads the same switches from the page's query string instead: ?nebula-name=Jesse&nebula-connect.

Fields

SecretSwitches

public static readonly string[] SecretSwitches =
{
    "nebula-token",
    "nebula-auth-key",
    "nebula-cloud-token",
    "nebula-cloud-deployment-token",
    "nebula-database",
};

Switches whose value is a credential: Redact hides them.

Properties

Keys

public static IReadOnlyCollection<string> Keys { get; }

Every switch that was parsed, for a service that forwards a whole family of them (-nebula-ext-*) to a process it launches.

Methods

ParseArgs

public static void ParseArgs(IReadOnlyList<string> raw, int start, IDictionary<string, string> into);

Adds switches from an argument vector to into, starting at start (1 skips the executable). Both spellings work: -key value and -key=value; the second is the only way to pass a value that itself starts with a dash (-heading=-30). A switch with no value maps to the empty string.

ParseQuery

public static void ParseQuery(string url, IDictionary<string, string> into);

Adds the parameters of a URL's query string ("a=1&b") to into, URL-decoded, with any leading dashes removed from the keys.

Redact

public static string Redact(string commandLine);

A command line as text, for a log line, with the values of SecretSwitches replaced by ***. Handles -key value and -key=value; a value in quotes is hidden whole.

Override

public static void Override(IDictionary<string, string> values);

For tests/editor: pretend these arguments were passed.

Has

public static bool Has(string key);

Get

public static string Get(string key, string fallback = null);

GetInt

public static int GetInt(string key, int fallback);

GetUInt

public static uint GetUInt(string key, uint fallback);

GetFloat

public static float GetFloat(string key, float fallback);

GetBool

public static bool GetBool(string key, bool fallback);

On this page