~adam-rpconnelly/dbversion/msbuild

« back to all changes in this revision

Viewing changes to src/DatabaseVersion.Console/Command/Version/DisplayVersionCommand.cs

  • Committer: Adam Connelly
  • Date: 2011-09-06 19:36:41 UTC
  • Revision ID: adam.rpconnelly@gmail.com-20110906193641-i1y2v10z652mildg
Adding the version command.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
namespace dbversion.Console.Command.Version
 
2
{
 
3
    using System.ComponentModel.Composition;
 
4
    using System.Diagnostics;
 
5
 
 
6
    /// <summary>
 
7
    /// Displays the current application version.
 
8
    /// </summary>
 
9
    [Export(typeof(IConsoleCommand))]
 
10
    public class DisplayVersionCommand : IConsoleCommand
 
11
    {
 
12
        /// <summary>
 
13
        /// Gets or sets the message service.
 
14
        /// </summary>
 
15
        /// <value>
 
16
        /// The message service.
 
17
        /// </value>
 
18
        [Import]
 
19
        public IMessageService MessageService
 
20
        {
 
21
            get;
 
22
            set;
 
23
        }
 
24
 
 
25
        /// <summary>
 
26
        /// Gets the name of the command.
 
27
        /// </summary>
 
28
        /// <value>
 
29
        /// The name of the command.
 
30
        /// </value>
 
31
        public string Name
 
32
        {
 
33
            get { return "version"; }
 
34
        }
 
35
 
 
36
        /// <summary>
 
37
        /// Execute the command using the specified args.
 
38
        /// </summary>
 
39
        /// <param name='args'>
 
40
        /// The arguments.
 
41
        /// </param>
 
42
        public void Execute(string[] args)
 
43
        {
 
44
            var assembly = typeof(DisplayVersionCommand).Assembly;
 
45
            var assemblyName = typeof(DisplayVersionCommand).Assembly.GetName();
 
46
            var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
 
47
 
 
48
            this.MessageService.WriteLine(string.Format("{0} {1}", assemblyName.Name, assemblyName.Version));
 
49
            this.MessageService.WriteLine(fileVersionInfo.LegalCopyright);
 
50
            this.MessageService.WriteLine("License MIT: The MIT License");
 
51
            this.MessageService.WriteLine("This is free software: you are free to change and redistribute it.");
 
52
            this.MessageService.WriteLine("There is NO WARRANTY, to the extent permitted by law.");
 
53
        }
 
54
    }
 
55
}
 
56