private async Task RunDelete() { base.CheckForValue(this._taskAssignmentId.Value, this._app, "A task assignment ID is required for this command"); var boxClient = base.ConfigureBoxClient(oneCallAsUserId: base._asUser.Value(), oneCallWithToken: base._oneUseToken.Value()); bool deleted; try { deleted = await boxClient.TasksManager.DeleteTaskAssignmentAsync(this._taskAssignmentId.Value); if (deleted) { Reporter.WriteSuccess($"Successfully deleted task {this._taskAssignmentId.Value}."); } else { Reporter.WriteError("Couldn't delete task."); } } catch (Exception e) { Reporter.WriteError("Couldn't delete task."); Reporter.WriteError(GeneralUtilities.FormatErrorResponseFromAPI(e)); } }
static int Main(string[] args) { var builder = new ConfigurationBuilder(); Configuration = builder.Build(); IServiceCollection serviceCollection = new ServiceCollection(); ConfigureServices(serviceCollection); Services = serviceCollection.BuildServiceProvider(); try { var app = new CommandLineApplication(); var root = Services.GetService <RootCommand>(); _app = app; root.Configure(app); return(app.Execute(args)); } catch (AggregateException aggEx) { if (aggEx.InnerException.GetType() == typeof(BoxSessionInvalidatedException)) { Reporter.WriteError("Token not valid."); Reporter.WriteError("Please try another token with the --token option."); } else if (aggEx != null && !string.IsNullOrEmpty(aggEx.Message)) { Reporter.WriteError(GeneralUtilities.FormatErrorResponseFromAPI(aggEx.InnerException)); } if (aggEx.InnerException != null) { if (aggEx.InnerException.GetType() == typeof(NoEnvironmentsFoundException)) { Reporter.WriteError("It looks like you haven't configured the Box CLI yet."); Reporter.WriteError("Use this command to start using the CLI: box configure environments add"); Reporter.WriteError("Or, supply a token with your command with --token."); } } return(1); } catch (Exception ex) { if (ex != null && !string.IsNullOrEmpty(ex.Message)) { Reporter.WriteError(GeneralUtilities.FormatErrorResponseFromAPI(ex)); } if (ex.InnerException != null) { if (ex.InnerException.GetType() == typeof(NoEnvironmentsFoundException)) { Reporter.WriteError("It looks like you haven't configured the Box CLI yet."); Reporter.WriteError("Use this command to start using the CLI: box configure environments add"); } } return(1); } }
private async Task RunDelete() { base.CheckForId(this._id.Value, this._app); base.CheckForScope(this._scope.Value, this._app); base.CheckForTemplate(this._template.Value, this._app); var boxClient = base.ConfigureBoxClient(oneCallAsUserId: base._asUser.Value(), oneCallWithToken: base._oneUseToken.Value()); try { bool didDeleteMetadata; if (this._dontPrompt.HasValue()) { didDeleteMetadata = await DeleteMetadata(boxClient); } else { Reporter.WriteWarningNoNewLine("Are you sure you want to delete this metadata? y/N "); var yNKey = "n"; yNKey = Console.ReadLine().ToLower(); if (yNKey != "y") { Reporter.WriteInformation("Aborted task deletion."); return; } else { didDeleteMetadata = await DeleteMetadata(boxClient); } } if (didDeleteMetadata) { Reporter.WriteSuccess($"Successfully deleted metadata {this._template.Value}."); } else { Reporter.WriteError("Couldn't delete this metadata."); } } catch (Exception e) { Reporter.WriteError("Couldn't delete this metadata."); Reporter.WriteError(GeneralUtilities.FormatErrorResponseFromAPI(e)); } }
private async Task RunDelete() { base.CheckForValue(this._taskId.Value, this._app, "A task ID is required for this command"); var boxClient = base.ConfigureBoxClient(oneCallAsUserId: base._asUser.Value(), oneCallWithToken: base._oneUseToken.Value()); bool deleted; try { if (this._dontPrompt.HasValue()) { deleted = await boxClient.TasksManager.DeleteTaskAsync(this._taskId.Value); } else { Reporter.WriteWarningNoNewLine("Are you sure you want to delete this task? y/N "); var yNKey = "n"; yNKey = Console.ReadLine().ToLower(); if (yNKey != "y") { Reporter.WriteInformation("Aborted task deletion."); return; } else { deleted = await boxClient.TasksManager.DeleteTaskAsync(this._taskId.Value); } } if (deleted) { Reporter.WriteSuccess($"Successfully deleted task {this._taskId.Value}."); } else { Reporter.WriteError("Couldn't delete task."); } } catch (Exception e) { Reporter.WriteError("Couldn't delete task."); Reporter.WriteError(GeneralUtilities.FormatErrorResponseFromAPI(e)); } }
private async Task RunDelete() { base.CheckForValue(this._commentId.Value, this._app, "A comment ID is required for this command"); bool deleted; try { if (this._dontPrompt.HasValue()) { deleted = await this.DeleteComment(); } else { Reporter.WriteWarningNoNewLine("Are you sure you want to delete this comment? y/N "); var yNKey = "n"; yNKey = Console.ReadLine().ToLower(); if (yNKey != "y") { Reporter.WriteInformation("Aborted comment deletion."); return; } else { deleted = await this.DeleteComment(); } } if (deleted) { Reporter.WriteSuccess($"Successfully deleted comment {this._commentId.Value}."); } else { Reporter.WriteError("Couldn't delete comment."); } } catch (Exception e) { Reporter.WriteError("Couldn't delete comment."); Reporter.WriteError(GeneralUtilities.FormatErrorResponseFromAPI(e)); } }