|
| 1 | +## **Application** |
| 2 | + |
| 3 | +I don't write GUI code, wither Windows or Web based. Most of my applications |
| 4 | +focus on the single command, a command shell or a service. This project |
| 5 | +reflects that basis. |
| 6 | + |
| 7 | +### **The command line** |
| 8 | + |
| 9 | +There is a common command line syntax. This allows for a familiar exerience |
| 10 | +with each command. You can use either an option switch of "/", "-" or "--" to |
| 11 | +preface your options. You can not mix the option switches within one command |
| 12 | +line. Words without a preceding switch are considered parameters. Multiple words |
| 13 | +that make up one parameter should be quoted. Single character options can be |
| 14 | +stacked and should begain with eithter a "/" or "-". The stacked options must |
| 15 | +be unique from long word options. Long word options must be complete, there |
| 16 | +are no abreviations. Options processing stops at a standalone "--" and the |
| 17 | +rest the command line is passed verbatiom. Environment variables within the |
| 18 | +command line are parsed and their values subsituted in place. |
| 19 | + |
| 20 | +### **Common options** |
| 21 | + |
| 22 | +Each application, wither it is cli, shell or service based has the same |
| 23 | +common set of options. They are as follows: |
| 24 | + |
| 25 | + -alerts - toggles the sending of alerts. |
| 26 | + -debug - toggles debug output to the log. |
| 27 | + -trace - toggles trace output to the log. |
| 28 | + -version|v - outputs the programs version. |
| 29 | + -help|h|? - outputs a simple help message. |
| 30 | + -manual - outputs the progams manual. |
| 31 | + -facility= - sets the alert facility. |
| 32 | + -priority= - sets the alert priority. |
| 33 | + -log-type= - toggles the log type. |
| 34 | + -log-file= - names the log file to use. |
| 35 | + -log-conf= - alternative logging configuration file. |
| 36 | + |
| 37 | +A command line application adds this option: |
| 38 | + |
| 39 | + -minwin - minimizes the console window. |
| 40 | + |
| 41 | +A service application adds these options: |
| 42 | + |
| 43 | + -install|i - install the service. |
| 44 | + -uninstall|u - uninstall the service. |
| 45 | + |
| 46 | +A common optional option is: |
| 47 | + |
| 48 | + -cfg-file= - use an alternative configuration file. |
| 49 | + |
| 50 | +The demo applications show how to use this common option. |
| 51 | + |
| 52 | +### **Configuration files** |
| 53 | + |
| 54 | +When an application starts up, it can process an optional configuration |
| 55 | +file. This file is located at %XAS_ETC%\<application name>.ini. This |
| 56 | +uses the familiar windows .ini style of config file. I find this style |
| 57 | +is more readable then Microsofts app.config format. When the configuration |
| 58 | +is loaded, the following stanza is processed. |
| 59 | + |
| 60 | + [application] |
| 61 | + alerts = true - default is true. |
| 62 | + facility = testing - default is "system". |
| 63 | + priority = low - default is "low". |
| 64 | + trace = true - default is false. |
| 65 | + debug = false - default is false. |
| 66 | + log-type = file - default is "console". |
| 67 | + log-file = <filename> - the path to a log file. |
| 68 | + log-conf = <filename> - the path to log4net configuration file. |
| 69 | + |
| 70 | +This set defaults for the application. These can be overridden on the |
| 71 | +command line. This makes it very easy to modify the behavior of a service. |
| 72 | +Something that is not easy to do from the command line. |
| 73 | + |
| 74 | +The following takes a boolean value: |
| 75 | + |
| 76 | + alerts |
| 77 | + trace |
| 78 | + debug |
| 79 | + |
| 80 | +Boolean values use the following verbage: |
| 81 | + |
| 82 | + boolean => true = yes, 1, true |
| 83 | + boolean => false = no, 0, false |
| 84 | + |
| 85 | +Alerting is built into the application. The following is used to |
| 86 | +control the serverity of the alert. |
| 87 | + |
| 88 | + facility - free form text |
| 89 | + priority - free form text |
| 90 | + |
| 91 | +This can be anything that has meaning for your alerting platform. When |
| 92 | +an alert is generated, it creates a spool file in %XAS_SPOOL%\alerts. |
| 93 | + |
| 94 | + log-type - "console", "file", "json" or "event" |
| 95 | + |
| 96 | +A log type of "file" will use a file to record the log into. By default |
| 97 | +this is located at %XAS_LOG%\<application name>.log. A log type of |
| 98 | +"json" will create a spool file in %XAS_SPOOL%\logs. A log type of "event" |
| 99 | +will create an entry in the Windows Event Log using the "Application" area. |
| 100 | + |
| 101 | + log-conf |
| 102 | + |
| 103 | +This is used to specify an alterntaive log4net configuration. |
| 104 | + |
| 105 | +Spooling is used to decouple the local application from a remote resource. |
| 106 | +It is much easier to write a local spool file then to connect to a remote |
| 107 | +resource. Especially when that remote resource is unavailable. |
| 108 | + |
| 109 | + |
0 commit comments