Skip to content

Commit

Permalink
Added more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
crisfervil committed Nov 1, 2017
1 parent d78fd91 commit 76daa0a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 24 deletions.
34 changes: 20 additions & 14 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Name | Description
--- | ---
-f, --file | File containing the data to import
-e, --continue-on-error | Continue if there's an error while processing the command
-c, --connection | Connection string, or name of a connection string to use
-c, --connection | Required. Connection string, or name of a connection string to use
-f, --config-file | Xml file containing the command options
-l, --log-level | Sets the current logging output. Can be Debug, Info, Error

Expand All @@ -22,12 +22,12 @@ Updates a specific column from a data table querying data in CRM
Name | Description
--- | ---
-f, --file | File containing the data table with the data
-l, --column | Name of the column to lookup
-l, --column | Required. Name of the column to lookup
-n, --entity | Name of the entity where search for the data
-m, --match-attributes | Attributes used to know if the record exists. Default is display attribute
-y, --match-columns | Columns containing the with the data to lookup. The number of columns must match the number of matching attributes
-e, --continue-on-error | Continue if there's an error while processing the command
-c, --connection | Connection string, or name of a connection string to use
-c, --connection | Required. Connection string, or name of a connection string to use
-f, --config-file | Xml file containing the command options
-l, --log-level | Sets the current logging output. Can be Debug, Info, Error

Expand All @@ -40,7 +40,7 @@ Publishes all existing customizations in the environment

Name | Description
--- | ---
-c, --connection | Connection string, or name of a connection string to use
-c, --connection | Required. Connection string, or name of a connection string to use
-f, --config-file | Xml file containing the command options
-l, --log-level | Sets the current logging output. Can be Debug, Info, Error

Expand All @@ -55,7 +55,7 @@ Name | Description
--- | ---
-q, --fetch-query | Fetch query to retrieve the records to delete
-e, --continue-on-error | Continue if there's an error while processing the command
-c, --connection | Connection string, or name of a connection string to use
-c, --connection | Required. Connection string, or name of a connection string to use
-f, --config-file | Xml file containing the command options
-l, --log-level | Sets the current logging output. Can be Debug, Info, Error

Expand All @@ -74,19 +74,19 @@ Name | Description
-q, --fetch-query | Fetch query to retrieve the records to export
-s, --page-size | Number of records to retrieve from a page
-p, --page | Page of records to retrieve
-c, --connection | Connection string, or name of a connection string to use
-c, --connection | Required. Connection string, or name of a connection string to use
-f, --config-file | Xml file containing the command options
-l, --log-level | Sets the current logging output. Can be Debug, Info, Error


## Examples
Export all the existing accounts to an Accounts.xml file
```
xrm --file Accounts.xml --entity account --connection DEV
xrm export --file Accounts.xml --entity account --connection DEV
```
Export all the existing contacts returned by a fetch query to the contacts.xml file
```
xrm --file Contacts.xml --connection DEV --config-file ContactsQuery.xml
xrm export --file Contacts.xml --connection DEV --config-file ContactsQuery.xml
```

# import
Expand All @@ -100,7 +100,7 @@ Name | Description
-f, --file | File containing the data to import
-e, --continue-on-error | Continue if there's an error while processing the command
-m, --match-attributes | Attributes used to know if the record exists. Default is id attribute
-c, --connection | Connection string, or name of a connection string to use
-c, --connection | Required. Connection string, or name of a connection string to use
-f, --config-file | Xml file containing the command options
-l, --log-level | Sets the current logging output. Can be Debug, Info, Error

Expand All @@ -113,24 +113,30 @@ Imports the specified solution .zip file into CRM

Name | Description
--- | ---
-s, --solution-file | .zip file containing the solution to import
-s, --solution-file | Required. .zip file containing the solution to import
-a, --async | Indicates wether the import should be performed asynchronously
-c, --connection | Connection string, or name of a connection string to use
-c, --connection | Required. Connection string, or name of a connection string to use
-f, --config-file | Xml file containing the command options
-l, --log-level | Sets the current logging output. Can be Debug, Info, Error


# solution-export

Export the specified solution to a .zip file
Exports the specified solution to a .zip file

## Options

Name | Description
--- | ---
-s, --solution-name | Unique name of the solution to export
-c, --connection | Connection string, or name of a connection string to use
-s, --solution-name | Required. Unique name of the solution to export
-c, --connection | Required. Connection string, or name of a connection string to use
-f, --config-file | Xml file containing the command options
-l, --log-level | Sets the current logging output. Can be Debug, Info, Error


## Examples
Export mysolution to the mysolution.zip file in the current directory
```
xrm solution-export --solution-name mysolution --connection TestEnvironment
```

10 changes: 5 additions & 5 deletions src/DocGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class CommandOption
public string HelpText { get; set; }
public string Summary { get; set; }
public string Remarks { get; set; }
public bool Hidden { get; set; }
public bool Required { get; set; }
}

class CommandExample
Expand Down Expand Up @@ -80,10 +82,9 @@ static void Main(string[] args)

foreach (var commandOption in optionAttrs)
{
if (!commandOption.OptionAttribute.Hidden)
{
commandInfo.Options.Add(new CommandOption() { ShortName=commandOption.OptionAttribute.ShortName, LongName=commandOption.OptionAttribute.LongName, HelpText=commandOption.OptionAttribute.HelpText });
}
commandInfo.Options.Add(new CommandOption() { ShortName=commandOption.OptionAttribute.ShortName, LongName=commandOption.OptionAttribute.LongName,
HelpText=commandOption.OptionAttribute.HelpText, Hidden=commandOption.OptionAttribute.Hidden,
Required=commandOption.OptionAttribute.Required});
}

var usageProperties = optionType.GetProperties().Where(x => x.GetCustomAttribute(typeof(UsageAttribute)) != null).ToList();
Expand All @@ -104,7 +105,6 @@ static void Main(string[] args)
foreach (var optionAttr in optionAttrs)
{
// get the property vaue
//System.Diagnostics.Debugger.Break();
var propValue = optionAttr.Property.GetMethod.Invoke(example.Sample, null);
if (propValue != null)
{
Expand Down
6 changes: 4 additions & 2 deletions src/DocGenerator/template.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
Name | Description
--- | ---
{{#Options}}
-{{ShortName}}, --{{LongName}} | {{HelpText}}
{{^Hidden}}
-{{ShortName}}, --{{LongName}} | {{#Required}}Required. {{/Required}}{{HelpText}}
{{/Hidden}}
{{/Options}}

{{#Examples.length}}
Expand All @@ -17,7 +19,7 @@ Name | Description
{{#Examples}}
{{HelpText}}
```
{{ApplicationAlias}} {{#Values}}{{^IsDefault}} --{{OptionLongName}} {{ParamValue}}{{/IsDefault}}{{/Values}}
{{ApplicationAlias}} {{Name}}{{#Values}}{{^IsDefault}} --{{OptionLongName}} {{ParamValue}}{{/IsDefault}}{{/Values}}
```
{{/Examples}}
{{/Examples.length}}
Expand Down
3 changes: 1 addition & 2 deletions src/XrmCommandBox/CrmCommonOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ namespace XrmCommandBox
{
public class CrmCommonOptions : CommonOptions
{
[Option('c', "connection", Required = true,
HelpText = "Connection string, or name of a connection string to use")]
[Option('c', "connection", Required = true, HelpText = "Connection string, or name of a connection string to use")]
public string ConnectionName { get; set; }

// public IOrganizationService Connection { get; set; }
Expand Down
14 changes: 13 additions & 1 deletion src/XrmCommandBox/Tools/SolutionExportToolOptions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
using CommandLine;
using CommandLine.Text;
using System.Collections.Generic;

namespace XrmCommandBox.Tools
{
[Verb("solution-export", HelpText = "Export the specified solution to a .zip file")]
[Verb("solution-export", HelpText = "Exports the specified solution to a .zip file")]
[Handler(typeof(SolutionExportTool))]
public class SolutionExportToolOptions : CrmCommonOptions
{
[Option('s', "solution-name", Required = true, HelpText = "Unique name of the solution to export")]
public string SolutionName { get; set; }

[Usage(ApplicationAlias = "xrm")]
public static IEnumerable<Example> Examples
{
get
{
yield return new Example("Export mysolution to the mysolution.zip file in the current directory",
new SolutionExportToolOptions { ConnectionName = "TestEnvironment", SolutionName = "mysolution" });
}
}
}
}

0 comments on commit 76daa0a

Please sign in to comment.