Creating a simple console application

The most commonly created type of command-line (CLI) application is one that performs a single discrete functionality, and can optionally display help about its usage.

This section will guide you through creating such an application using the ConsoleFx.Programs.Simple.ConsoleProgram class. This class hides the more advanced concepts of ConsoleFx and allows you to focus on creating a typical CLI application.

The CLI application that we will be creating is a file backup application called BACKUP that can backup the contents of a directory to a ZIP file. (Note: we will only be demonstrating the command-line handling; the code will not contain any logic to actually perform a backup).
The source code for this guide is available under the samples\GettingStarted\ConsoleProgram directory.

The signature and usage of BACKUP is shown below:

BACKUP [-verbose] [-type:Full|Incremental] [-exclude:mask1,mask2,...] <directory> <zip file path>
  • -verbose (short: v; optional; default: false): If specified, the application will output detailed information about the backup process to the console as it is executing.
  • -type (short: t; optional; default: Full): The type of backup to perform... a full backup or an incremental backup.
  • -exclude (short: e; optional): Specifies one or more DOS file masks that specify the files to exclude from the backup.
  • <directory>: The directory to backup. The specified directory must exist.
  • <zip file path>: The name of the ZIP file to which the directory will be backed up.

Table of Contents

  1. Setting up the project
  2. Defining the application options
  3. Defining the application arguments
  4. Auto generated usage help

Last edited Jun 20, 2012 at 7:36 AM by jeevanjj, version 6

Comments

No comments yet.