Skip to content

Commit

Permalink
Merge pull request #76 from box/quick-cleanup
Browse files Browse the repository at this point in the history
Fixed redundant group membership command, fixed metadata template cre…
  • Loading branch information
allenmichael authored Apr 3, 2018
2 parents 947405d + 08ab624 commit 4de873d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public override void Configure(CommandLineApplication command)
command.Description = "Work with group memberships in Box.";
command.ExtendedHelpText = "You can use this command to create, update, delete, and get information about group memberships in your Enterprise.";
command.Command(_names.SubCommandNames.Get, _subCommands.CreateSubCommand(_names.SubCommandNames.Get).Configure);
command.Command(_names.SubCommandNames.Create, _subCommands.CreateSubCommand(_names.SubCommandNames.Create).Configure);
command.Command(_names.SubCommandNames.Add, _subCommands.CreateSubCommand(_names.SubCommandNames.Add).Configure);
command.Command(_names.SubCommandNames.Update, _subCommands.CreateSubCommand(_names.SubCommandNames.Update).Configure);
command.Command(_names.SubCommandNames.List, _subCommands.CreateSubCommand(_names.SubCommandNames.List).Configure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ public override ISubCommand CreateSubCommand(string commandName)
{
return new GroupMembershipListCommand(_boxPlatformBuilder, _boxHome, _names);
}
else if (commandName == base._names.SubCommandNames.Create)
{
return new GroupMembershipCreateCommand(_boxPlatformBuilder, _boxHome, _names);
}
else
{
throw new Exception("Command not registered.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override void Configure(CommandLineApplication command)
_templateKey = command.Option("--template-key", "A unique identifier for the template.", CommandOptionType.SingleValue);
_hidden = command.Option("--hidden", "Whether this template is hidden in the UI.", CommandOptionType.NoValue);
_bulkFilePaths = command.Option("--bulk-file-path-csv",
"Provide file paths for the metadata temple CSV file and metadata template fields CSV file",
"Provide file paths for the metadata template CSV file and metadata template fields CSV file, ex: box metadata-templates create --bulk-file-path-csv /path/to/template.csv --bulk-file-path-csv /path/to/fields.csv",
CommandOptionType.MultipleValue);
_bulkFilePath = BulkFilePathOption.ConfigureOption(command);
_idOnly = IdOnlyOption.ConfigureOption(command);
Expand Down Expand Up @@ -74,6 +74,12 @@ private async Task RunCreate()
}
if (this._bulkFilePath.HasValue())
{
var json = false;
if (base._json.HasValue() || this._home.GetBoxHomeSettings().GetOutputJsonSetting())
{
json = true;
}
await base.CreateMetadataTemplatesFromFile(this._bulkFilePath.Value(), json: json);
return;
}
base.CheckForScope(this._scope.Value, this._app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ protected async virtual Task CreateMetadataTemplatesFromFile(string filePath, st
List<BoxMetadataTemplate> templateRequests;
if (fileFormat.ToLower() == base._settings.FILE_FORMAT_CSV)
{
if (string.IsNullOrEmpty(filePathFields))
{
throw new Exception("You must use the --bulk-file-path-csv option with metadata templates and provide file paths to CSV files for the tempate and the template fields.");
}
templateRequests = this.ReadMetadataTemplateCsvFile(filePath, filePathFields);
}
else if (fileFormat.ToLower() == base._settings.FILE_FORMAT_JSON)
Expand Down

0 comments on commit 4de873d

Please sign in to comment.