NTP Analyzer
0.8.2
Analyze the operation of time servers
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
HelpCommand.cs
Go to the documentation of this file.
1
//
2
// Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net>
3
//
4
// Permission is hereby granted, free of charge, to any person obtaining a copy
5
// of this software and associated documentation files (the "Software"), to deal
6
// in the Software without restriction, including without limitation the rights
7
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
// copies of the Software, and to permit persons to whom the Software is
9
// furnished to do so, subject to the following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included in
12
// all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
// THE SOFTWARE.
21
22
using
System
.Linq;
23
using
System
.Text;
24
25
namespace
Ntp
.Analyzer.Monitor.Server.TextCommand
26
{
27
internal
sealed
class
HelpCommand
:
MonitorTextCommand
28
{
29
public
HelpCommand
(
string
[] args)
30
: base(args)
31
{
32
}
33
34
public
HelpCommand
(
bool
error)
35
: base(new string[0])
36
{
37
this.error = error;
38
}
39
40
private
readonly
bool
error
;
41
42
protected
override
string
ExecuteTextCommand
()
43
{
44
var builder =
new
StringBuilder();
45
46
if
(error)
47
{
48
builder.AppendLine(
"Unknown command."
);
49
builder.AppendLine();
50
}
51
52
var
version
=
new
VersionCommand
(
new
string
[0]);
53
builder.Append(version.Execute());
54
builder.AppendLine(
". the following commands are valid."
);
55
56
int
length =
CommandFactory
.
Commands
.Max(
c
=>
c
.Description.Length);
57
length += 15 + 3;
58
59
builder.AppendLine(
string
.Empty.PadLeft(length,
'-'
));
60
61
foreach
(
ICommandDescription
command
in
CommandFactory
.
Commands
.OrderBy(
c
=>
c
.Name))
62
{
63
builder.Append(command.
Name
.PadRight(15));
64
builder.AppendLine(command.
Description
);
65
}
66
67
return
builder.ToString();
68
}
69
}
70
}
Ntp.Analyzer.Monitor.Server.TextCommand.HelpCommand.error
readonly bool error
Definition:
HelpCommand.cs:40
Ntp.Analyzer.Monitor.Server.ICommandDescription.Description
string Description
Definition:
ICommandDescription.cs:29
Ntp.Analyzer.Monitor.Server.TextCommand.MonitorTextCommand
Definition:
MonitorTextCommand.cs:24
Ntp.Analyzer.Monitor.Server.TextCommand.VersionCommand
Definition:
VersionCommand.cs:24
Ntp
c
var c
Definition:
bootstrap.min.js:6
System
Ntp.Analyzer.Monitor.Server.TextCommand.HelpCommand.HelpCommand
HelpCommand(string[] args)
Definition:
HelpCommand.cs:29
Ntp.Analyzer.Monitor.Server.TextCommand.HelpCommand.ExecuteTextCommand
override string ExecuteTextCommand()
Definition:
HelpCommand.cs:42
Ntp.Analyzer.Monitor.Server.TextCommand.HelpCommand.HelpCommand
HelpCommand(bool error)
Definition:
HelpCommand.cs:34
Ntp.Analyzer.Monitor.Server.ICommandDescription.Name
string Name
Definition:
ICommandDescription.cs:28
Ntp.Analyzer.Monitor.Server.CommandFactory.Commands
static readonly IList< ICommandDescription > Commands
Definition:
CommandFactory.cs:31
Ntp.Analyzer.Monitor.Server.ICommandDescription
Definition:
ICommandDescription.cs:26
version
var version
Definition:
bootstrap.js:13
Ntp.Analyzer.Monitor.Server.CommandFactory
Definition:
CommandFactory.cs:29
Ntp.Analyzer.Monitor.Server.TextCommand.HelpCommand
Definition:
HelpCommand.cs:27
Ntp.Analyzer.Monitor.Server
TextCommand
HelpCommand.cs
Generated by
1.8.11