Skip to content

Commit

Permalink
Added structured output for creating and updating code templates, com…
Browse files Browse the repository at this point in the history
…mands and launch points. #79
  • Loading branch information
Jezz Santos committed May 13, 2023
1 parent b3d4b5f commit 2d89000
Show file tree
Hide file tree
Showing 15 changed files with 833 additions and 113 deletions.
19 changes: 14 additions & 5 deletions docs/authoring.md
Expand Up @@ -524,14 +524,17 @@ automate edit add-codetemplate-with-command "<FILEPATH>" --targetpath "<TARGETPA

- The `--name` is an optional friendly name of the code template, which will be used to reference the code template when it is connected to automation later. If no name is specified, an automatic name is assigned to this code template.

- The `--commandname` optionally defines a new name for the command. If no name is specified, an automatic name is assigned to this command.


!!! example
To the pattern:
``` batch
automate edit add-codetemplate-with-command "C:/projects/src/afilename.ext" --name "ATemplateName" --targetpath "~/apath/afilename.ext" --isoneoff
automate edit add-codetemplate-with-command "C:/projects/src/afilename.ext" --name "ATemplateName" --commandname "ACommandName" --targetpath "~/apath/afilename.ext" --isoneoff
```
To an element:
``` batch
automate edit add-codetemplate-with-command "C:/projects/src/afilename.ext" --name "ATemplateName" --targetpath "~/apath/afilename.ext" --isoneoff --aschildof "{AnElementName}"
automate edit add-codetemplate-with-command "C:/projects/src/afilename.ext" --name "ATemplateName" --commandname "ACommandName" --targetpath "~/apath/afilename.ext" --isoneoff --aschildof "{AnElementName}"
```

### Update code template commands
Expand All @@ -549,7 +552,7 @@ automate edit update-codetemplate-command "<COMMANDNAME>" --aschildof "{<ANEXPRE

- The `--isoneoff` optionally defines that the rendered code template will only be generated if it does not already exist on the local machine in the specified location with the specified name. Typically, this means that the code template is only rendered the first time the command is executed.

- The `--name` optionally defines a new name for the command.
- The `--name` optionally defines a new name for the command. If no name is specified, an automatic name is assigned to this command.

!!! example
Of the pattern:
Expand Down Expand Up @@ -609,7 +612,7 @@ automate edit add-cli-command "<APPLICATIONNAME>" --aschildof "{<ANEXPRESSION>}"

- The `--arguments <ARGUMENTS>` optionally defines the arguments to pass to the program. Double-quotes in the arguments must be escaped with double-quotes. The arguments may also contain [Templating Expressions](reference.md#templating-expressions) (relative to the element/collection of the value of `--aschildof`), which will be resolved when the command is applied.

- The `--name` optionally defines a name for the command. If none is given, a default name will be derived for the command.
- The `--name` optionally defines a name for the command. If no name is specified, an automatic name is assigned to this command.

!!! example
To the pattern:
Expand Down Expand Up @@ -722,8 +725,10 @@ automate edit update-command-launchpoint "<LAUNCHPOINTNAME>" --add "<COMMANDIDEN

- The `--aschildof "{<ANEXPRESSION>}"` is only optional if you are updating a launch point on the root element. `<ANEXPRESSION>` is an [Expression](reference.md#pattern-expressions) to an existing element/collection in the pattern.

- The `--add <COMMANDIDENTIFIERS>` optionally defines the new `;` delimited list of command identifiers (on the target element/collection) or it can be `*` to indicate that you want to add all the commands (on the `--from` element/collection). By using `*` you can update the list to add or remove any commands that have changed.
- The `--add <COMMANDIDENTIFIERS>` defines the new `;` delimited list of command identifiers (on the target element/collection) to add, or it can be `*` to indicate that you want to add all the commands (on the `--from` element/collection). By using `*` you can update the list to add or remove any commands that have changed.

- The `--remove <COMMANDIDENTIFIERS>` optionally defines the new `;` delimited list of command identifiers (on the target element/collection) to remove, or it can be `*` to indicate that you want to remove all the commands (on the `--from` element/collection).

- The `--from` optionally defines another element/collection in the pattern where the commands are located. If this is omitted, then it is assumed that the commands exist on the `--aschildof` element/collection.

- The `--name` optionally defines a new name for the launch point.
Expand All @@ -733,6 +738,10 @@ automate edit update-command-launchpoint "<LAUNCHPOINTNAME>" --add "<COMMANDIDEN
``` batch
automate edit update-command-launchpoint "ALaunchPointName" --add "*" --name "ANewLaunchPointName"
```
Of the pattern, to clear, and add only specific commands on the pattern:
``` batch
automate edit update-command-launchpoint "ALaunchPointName" --remove "*" --add "<ACMDID>" --name "ANewLaunchPointName"
```
Of an element, to re-add all commands from another element:
``` batch
automate edit update-command-launchpoint "ALaunchPointName" --add "*" --name "ANewLaunchPointName" --from "{AnotherElementName}" --aschildof "{AnElementName}"
Expand Down
18 changes: 18 additions & 0 deletions src/Automate.sln.DotSettings
Expand Up @@ -1142,6 +1142,8 @@ namespace $NAMESPACE$
<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=C2A67BDE45A535439EDEFFF8E19B9B72/Name/@EntryValue">(?&lt;=\W|^)(?&lt;TAG&gt;BUG)(\W|$)(.*)</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=C2A67BDE45A535439EDEFFF8E19B9B72/Pattern/@EntryValue">(?&lt;=\W|^)(?&lt;TAG&gt;BUG)(\W|$)(.*)</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=C2A67BDE45A535439EDEFFF8E19B9B72/TodoIconStyle/@EntryValue">Edit</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=achoice/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=acmdid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=acollectioname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=acollectionexpression/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=acollectionname/@EntryIndexedValue">True</s:Boolean>
Expand All @@ -1151,31 +1153,46 @@ namespace $NAMESPACE$
<s:Boolean x:Key="/Default/UserDictionary/Words/=adescription/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=adisplayname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=adraftid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=afileextension/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=afilename/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=afilepath/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=afullpath/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=alaunchpointname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=alog/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=amachineid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=amessage/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=amessagetemplate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=aname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anapp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anapplicationname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anarg/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anargument/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anattributename/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anautomationname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anelement/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anelementexpression/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anelementname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=aneventname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anewapplicationname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anewargument/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anewcontent/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anewdefaultvalue/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anewname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anewpath/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anewvalue/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anextension/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=aninstallationid/@EntryIndexedValue">True</s:Boolean>

<s:Boolean x:Key="/Default/UserDictionary/Words/=aninstallerlocation/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=aninvalidname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=aninvalidpropertyassignment/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Anonymise/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anoperationid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anotherattributename/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anotherelementname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anunknownattribute/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=apath/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=apatternname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=appsettings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=aproductname/@EntryIndexedValue">True</s:Boolean>
Expand All @@ -1193,6 +1210,7 @@ namespace $NAMESPACE$
<s:Boolean x:Key="/Default/UserDictionary/Words/=codetemplate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=codetemplates/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=com/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=commandname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=defaultvalueis/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=describedas/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=displayedas/@EntryIndexedValue">True</s:Boolean>
Expand Down
7 changes: 4 additions & 3 deletions src/CLI.IntegrationTests/Infrastructure/Api/AuthoringSpec.cs
Expand Up @@ -600,12 +600,12 @@ public void WhenAddCodeTemplateWithCommand_ThenAddsTemplateAndCommand()
this.setup.Should().DisplayNoError();
this.setup.Should()
.DisplayOutput(
OutputMessages.CommandLine_Output_CodeTemplatedAdded.SubstituteTemplate("ATemplateName",
OutputMessages.CommandLine_Output_CodeTemplateAdded.SubstituteTemplate("ATemplateName",
codeTemplate.Id, pattern.Id, codeTemplate.Metadata.OriginalFilePath, codeTemplateLocation));
this.setup.Should()
.DisplayOutput(
OutputMessages.CommandLine_Output_CodeTemplateCommandAdded.SubstituteTemplate(
"ATemplateNameCommand1",
"CodeTemplateCommand1",
this.setup.Pattern.Automation.Single().Id, pattern.Id));
this.setup.Pattern.CodeTemplates.Should().ContainSingle(x => x.Name == "ATemplateName");
}
Expand Down Expand Up @@ -655,7 +655,8 @@ public void WhenViewCodeTemplate_ThenViewsTemplate()
this.setup.Should()
.DisplayOutput(
OutputMessages.CommandLine_Output_CodeTemplateContentViewed.SubstituteTemplate(codeTemplate.Name,
codeTemplate.Id, this.setup.Pattern.Id, codeTemplateLocation, content));
codeTemplate.Id, this.setup.Pattern.Id, codeTemplate.Metadata.OriginalFilePath,
codeTemplate.Metadata.OriginalFileExtension, codeTemplateLocation, content));
}

[Fact]
Expand Down

0 comments on commit 2d89000

Please sign in to comment.