Skip to content

Commit

Permalink
chore: Update torque-cli installation command to use latest version a…
Browse files Browse the repository at this point in the history
…nd GitHub package source
  • Loading branch information
davidbquali committed Jul 10, 2024
1 parent 1177e8d commit c38d29e
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 84 deletions.
80 changes: 40 additions & 40 deletions Quali.Torque.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,96 +37,96 @@ public static int Main(string[] args)
{
// TODO: log error once logging is ready
productValue = new ProductInfoHeaderValue(Constants.DefaultUserAgentValue, UserAgentUtils.GetCurrentVersion());
}
}
}

configure.DefaultRequestHeaders.UserAgent.Add(productValue);
});
services.AddSingleton<IUserProfilesManager, UserProfilesManager>();
services.AddSingleton<IEnvironmentProvider, EnvironmentProvider>();
services.AddSingleton<ITorqueConfigurationProvider, TorqueYamlConfigurationProvider>();

services.AddSingleton<IConsoleManager, SpectreConsoleManager>();
services.AddSingleton<IConsoleManager, SpectreConsoleManager>();
services.AddSingleton<IClientManager, ClientManager>();

var registrar = new TypeRegistrar(services);
var app = new CommandApp(registrar);

app.Configure(config =>
{
config.SetApplicationName("torque");
config.SetApplicationName("torque-cli");
config.ValidateExamples();

config.AddBranch("blueprint", blueprint =>
{
blueprint.SetDescription("Get, List, Validate blueprints.");

blueprint.AddCommand<BlueprintGetCommand>("get")
.WithDescription("Get blueprint by Name.")
.WithExample(new [] { "bp", "get", "MyBp"});
.WithExample(new[] { "bp", "get", "MyBp" });

blueprint.AddCommand<BlueprintListCommand>("list")
.WithDescription("List blueprints")
.WithExample(new [] { "bp", "list" });
.WithExample(new[] { "bp", "list" });

blueprint.AddCommand<BlueprintValidateCommand>("validate")
.WithDescription("Validate blueprint");

blueprint.AddCommand<BlueprintPublishCommand>("publish")
.WithDescription("Publish blueprint to catalog");

blueprint.AddCommand<BlueprintUnpublishCommand>("unpublish")
.WithDescription("Remove blueprint from catalog");
}).WithAlias("bp");

config.AddBranch("environment", environment =>
{
environment.SetDescription("Start, End, View Torque environments.");
environment.AddCommand<EnvironmentStartCommand>("start")
.WithDescription("Start Environment")
.WithExample(new[] {"env", "start", "demo", "--duration=100", "--name=MyDemoEnv"});
.WithExample(new[] { "env", "start", "demo", "--duration=100", "--name=MyDemoEnv" });

environment.AddCommand<EnvironmentBulkStartCommand>("bulkstart")
.WithDescription("Start Environment")
.WithExample(new[] {"env", "bulkstart", "<CSV file path>>"});
.WithExample(new[] { "env", "bulkstart", "<CSV file path>>" });

environment.AddCommand<EnvironmentGetCommand>("get")
.WithDescription("Get Environment Details")
.WithExample(new[] {"env", "get"});
.WithExample(new[] { "env", "get" });

environment.AddCommand<EnvironmentEndCommand>("end")
.WithDescription("End Torque Environment")
.WithExample(new []{"env", "end", "qwdj4jr9smf"});
.WithExample(new[] { "env", "end", "qwdj4jr9smf" });

environment.AddCommand<EnvironmentListCommand>("list")
.WithDescription("List Torque Environment")
.WithExample(new []{"env", "list", "--show-ended"});
.WithExample(new[] { "env", "list", "--show-ended" });

environment.AddCommand<EnvironmentExtendCommand>("extend")
.WithDescription("Extend Torque Environment")
.WithExample(new []{"env", "extend", "qwdj4jr9smf", "--duration", "120"});
.WithExample(new[] { "env", "extend", "qwdj4jr9smf", "--duration", "120" });
}).WithAlias("env");

config.AddBranch("config", configure =>
{
configure.SetDescription("List, Add and Modify user profiles");
configure.AddCommand<ConfigListCommand>("list")
.WithDescription("List all profiles")
.WithExample("config", "list");

configure.AddCommand<ConfigAddProfileCommand>("add")
.WithDescription("Add user profile")
.WithAlias("add");

configure.AddCommand<ConfigUpdateProfileCommand>("update")
.WithDescription("Update user profile")
.WithAlias("add");

configure.AddCommand<ConfigRemoveCommand>("remove")
.WithDescription("Remove specified profile")
.WithAlias("remove")
.WithExample("config", "remove", "myprofile");

configure.AddCommand<ConfigSetActiveCommand>("activate")
.WithDescription("Set active profile")
.WithExample("config", "activate", "myprofile");
Expand All @@ -138,11 +138,11 @@ public static int Main(string[] args)

agent.AddCommand<AgentsListCommand>("list")
.WithDescription("List agents in Space.")
.WithExample(new[] {"agent", "list", "mySpace"});
.WithExample(new[] { "agent", "list", "mySpace" });

agent.AddCommand<AgentAssociateWithSpaceCommand>("associate")
.WithDescription("Associate Agent with Space")
.WithExample(new[] {"agent", "associate", "myAgent", "mySpace", "--ns", "demo", "--sa", "mySA"});
.WithExample(new[] { "agent", "associate", "myAgent", "mySpace", "--ns", "demo", "--sa", "mySA" });
});

config.AddBranch("space", space =>
Expand All @@ -151,15 +151,15 @@ public static int Main(string[] args)

space.AddCommand<SpaceCreateCommand>("create")
.WithDescription("Create space")
.WithExample(new[] {"space", "create", "demo"});
.WithExample(new[] { "space", "create", "demo" });

space.AddCommand<SpaceDeleteCommand>("delete")
.WithDescription("Delete space")
.WithExample(new[] {"space", "delete", "demo"});
.WithExample(new[] { "space", "delete", "demo" });

space.AddCommand<SpaceListCommand>("list")
.WithDescription("Show list of spaces")
.WithExample(new[] {"space", "list"});
.WithExample(new[] { "space", "list" });

// space.AddCommand<SpaceAddRepoCommand>("connect")
// .WithDescription("Connect repo to space")
Expand All @@ -169,22 +169,22 @@ public static int Main(string[] args)
config.AddBranch("eac", eac =>
{
eac.SetDescription("Handle environment-as-code actions.");

eac.AddCommand<EacListCommand>("list")
.WithDescription("List all current Git-managed environments and their status.")
.WithExample(new[] {"eac", "list"});
.WithExample(new[] { "eac", "list" });

eac.AddCommand<ExportEacCommand>("export")
.WithDescription("Generates an environment YAML file from an existing environment.")
.WithExample(new[] {"eac", "export", "qwdj4jr9smf"});
.WithExample(new[] { "eac", "export", "qwdj4jr9smf" });

eac.AddCommand<RunPlanCommand>("plan")
.WithDescription("Runs a plan against an environment and returns the results.")
.WithExample(new[] {"eac", "plan", "qwdj4jr9smf"})
.WithExample(new[] {"eac", "plan", "qwdj4jr9smf", "-g", "myGrain"});
.WithExample(new[] { "eac", "plan", "qwdj4jr9smf" })
.WithExample(new[] { "eac", "plan", "qwdj4jr9smf", "-g", "myGrain" });
});
});

return app.Run(args);
}
}
82 changes: 38 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,22 @@ To learn more about Torque, visit [https://www.quali.com/torque/](https://www.qu

## Installing

* If you have the previous version of torque-cli(from Pypi) installed on your system please remove it first with:

`pip uninstall torque-cli`
* Right now there are two ways to use torque-cli:
* Install torque-cli as a .NET tool. In this case you need to have **dotnet** (version 7.0 or higher) installed.
To install dotnet, follow the link: https://dotnet.microsoft.com/en-us/download

```dotnet tool install -g torque --version ${VERSION} --add-source https://nuget.pkg.github.com/QualiNext/index.json```

For example:

```dotnet tool install -g torque --version 2.5.0 --add-source https://nuget.pkg.github.com/QualiNext/index.json```
```dotnet tool install -g torque-cli```

* Run torque-cli as a docker container:

```docker run -it qtorque/torque-cli:latest```
```docker run -it quali/torque-cli:latest```

```docker run -it qtorque/torque-cli:latest -v ~/.torque:/root/.torque/ # to mount your local torque config file```
* The old configuration file will not work, so you will have to re-create it with command: ```torque config set```
```docker run -it quali/torque-cli:latest -v ~/.torque:/root/.torque/ # to mount your local torque config file```
* The old configuration file will not work, so you will have to re-create it with command: ```torque-cli config set```

## Configuration

To allow the torque-cli to authenticate with Torque, you must provide several parameters:
To allow the `torque-cli` to authenticate with Torque, you must provide several parameters:
* *Space*: The Torque space to use
* *Repository*: (Optional) Represents the name of the git repository containing the bleprints and IaC files that will be used when calling Torque
* *Token*: The easiest way to generate a token is via the Torque UI.
Expand All @@ -41,16 +34,16 @@ To allow the torque-cli to authenticate with Torque, you must provide several pa

The ```Token```, ```Space``` and ```Repository``` parameters can be provided via a special command line flags (```--token```, ```--space```, and ```--repo```, respectively). You can also conveniently place these parameters in a config file relative to your user folder, so they don't need to be provided each time.

The config file can be created and managed using the interactive `torque config` command.
The config file can be created and managed using the interactive `torque-cli config` command.
The CLI supports multiple profiles, and you can switch between them by setting the active profile for ease of use. To use a non-active profile, the ```--profile_``` command-line flag needs to be used to specify the profile name.

To add a new profile or update an existing one, run ```torque config set``` and follow the on-screen directions.
To see all profiles, run ```torque config list``` and the command will output a table of all the profiles that are currently configured.
To add a new profile or update an existing one, run ```torque-cli config set``` and follow the on-screen directions.
To see all profiles, run ```torque-cli config list``` and the command will output a table of all the profiles that are currently configured.

Example output:

```bash
$ torque config list
$ torque-cli config list
Torque user profiles

Active │ Profile Name │ Space │ Repository │ Token
Expand All @@ -59,9 +52,9 @@ $ torque config list
test │ dev │ myrepo │ ******masd
```

If a profile is no longer needed, you can remove it by running: ```torque config remove <profile-name>```
If a profile is no longer needed, you can remove it by running: ```torque-cli config remove <profile-name>```

The ```torque config``` command saves the config file relative to your home user directory ('~/.torque/config.yml' on Mac and Linux or in the '%UserProfile%\\.torque\\config.yaml' file on Windows).
The ```torque-cli config``` command saves the config file relative to your home user directory (`~/.torque/config.yml` on Mac and Linux or in the `%UserProfile%\\.torque\\config.yaml` file on Windows).
To place the config file in a different location, specify that location via an environment variable:

```$ export TORQUE_CONFIG_PATH=/path/to/file```
Expand All @@ -87,56 +80,57 @@ export TORQUE_URL = "https://demo.qtorque.io"

There are some basic actions Torque CLI currently allows you to perform:

- Validate a blueprint (using the ```torque bp validate``` command)
- Get a list of blueprints (via ```torque bp list```)
- Start an environment (via ```torque env start```)
- Validate a blueprint (using the ```torque-cli bp validate``` command)
- Get a list of blueprints (via ```torque-cli bp list```)
- Start an environment (via ```torque-cli env start```)

To see the help files, run:

```$ torque --help```
```$ torque-cli --help```

It will give you detailed output with usage:

```shell
$ torque -h
$ torque-cli -h
USAGE:
torque [OPTIONS] <COMMAND>
torque-cli [OPTIONS] <COMMAND>

EXAMPLES:
torque bp get MyBp
torque bp list
torque env start demo --duration=100 --name=MyDemoEnv
torque env get
torque env end qwdj4jr9smf
torque-cli bp get MyBp
torque-cli bp list
torque-cli env start demo --duration=100 --name=MyDemoEnv
torque-cli env bulkstart <CSV file path>>
torque-cli env get

OPTIONS:
-h, --help Prints help information
-v, --version Prints version information
-h, --help Prints help information
-v, --version Prints version information

COMMANDS:
blueprint Get, List, Validate blueprints
environment Start, End, View Torque environments
config List, Add and Modify user profiles
agent List, associate agents
space Create, delete spaces, connect repo to space
blueprint Get, List, Validate blueprints
environment Start, End, View Torque environments
config List, Add and Modify user profiles
agent List, associate agents
space Create, delete spaces, connect repo to space
eac Handle environment-as-code actions
```

You can get additional help information for a particular command by including the ```--help``` flag after the command name, like:

```shell
$ torque env -h
$ torque-cli env -h
DESCRIPTION:
Start, End, View Torque environments.

USAGE:
torque environment [OPTIONS] <COMMAND>
torque-cli environment [OPTIONS] <COMMAND>

EXAMPLES:
torque env start demo --duration=100 --name=MyDemoEnv
torque env get
torque env end qwdj4jr9smf
torque env list --show-ended
torque env extend qwdj4jr9smf --duration 120
torque-cli env start demo --duration=100 --name=MyDemoEnv
torque-cli env get
torque-cli env end qwdj4jr9smf
torque-cli env list --show-ended
torque-cli env extend qwdj4jr9smf --duration 120

OPTIONS:
-h, --help Prints help information
Expand All @@ -154,7 +148,7 @@ COMMANDS:
The CLI allows for deplying multiple environments defined in a CSV file.

```shell
torque.exe env bulkstart <PATH-TO-CSV>
torque-cli env bulkstart <PATH-TO-CSV>
```
The lines of the CSV are itterated, starting an environment for each line. If a line specifies multiple owners, a separate environment (with the same parameters) will be started for each owner.
#### CSV format
Expand Down

0 comments on commit c38d29e

Please sign in to comment.