2011-02-10 14:32:38 +03:00
|
|
|
|
// XSDDiagram - A XML Schema Definition file viewer
|
|
|
|
|
// Copyright (C) 2006-2011 Regis COSNIER
|
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
|
|
using System;
|
2010-10-31 18:02:13 +03:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace XSDDiagram
|
|
|
|
|
{
|
|
|
|
|
public class Options
|
|
|
|
|
{
|
|
|
|
|
public static string[] Arguments { get; private set; }
|
|
|
|
|
public static string InputFile { get; private set; }
|
|
|
|
|
public static string OutputFile { get; private set; }
|
2016-02-27 14:58:48 +03:00
|
|
|
|
public static bool OutputOnStdOut { get; private set; }
|
|
|
|
|
public static string OutputOnStdOutExtension { get; private set; }
|
2010-10-31 18:02:13 +03:00
|
|
|
|
public static IList<string> RootElements { get; private set; }
|
|
|
|
|
public static int ExpandLevel { get; private set; }
|
2016-02-27 14:58:48 +03:00
|
|
|
|
public static bool ShowDocumentation { get; private set; }
|
|
|
|
|
public static float Zoom { get; private set; }
|
2012-07-23 03:18:33 +04:00
|
|
|
|
public static bool ForceHugeImageGeneration { get; private set; }
|
2010-10-31 18:02:13 +03:00
|
|
|
|
public static bool RequestHelp { get; private set; }
|
|
|
|
|
public static bool IsRunningOnMono { get; private set; }
|
2012-12-01 20:40:00 +04:00
|
|
|
|
public static string Username { get; private set; }
|
|
|
|
|
public static string Password { get; private set; }
|
2014-01-13 21:26:37 +04:00
|
|
|
|
public static IList<string> TextOutputFields { get; private set; }
|
2017-02-10 20:14:01 +03:00
|
|
|
|
public static bool DisplayAttributes { get; private set; }
|
2016-11-24 19:26:05 +03:00
|
|
|
|
public static bool NoGUI { get; private set; }
|
2010-10-31 18:02:13 +03:00
|
|
|
|
|
2016-11-24 19:26:05 +03:00
|
|
|
|
static Options()
|
2010-10-31 18:02:13 +03:00
|
|
|
|
{
|
|
|
|
|
InputFile = null;
|
|
|
|
|
OutputFile = null;
|
2010-11-01 03:10:19 +03:00
|
|
|
|
OutputOnStdOut = false;
|
|
|
|
|
OutputOnStdOutExtension = "png";
|
2010-10-31 18:02:13 +03:00
|
|
|
|
RootElements = new List<string>();
|
|
|
|
|
ExpandLevel = 0;
|
2016-02-27 14:58:48 +03:00
|
|
|
|
ShowDocumentation = false;
|
|
|
|
|
Zoom = 100.0f;
|
2012-07-23 03:18:33 +04:00
|
|
|
|
ForceHugeImageGeneration = false;
|
2010-10-31 18:02:13 +03:00
|
|
|
|
RequestHelp = false;
|
2014-01-13 21:26:37 +04:00
|
|
|
|
TextOutputFields = new List<string>();
|
2017-02-10 20:14:01 +03:00
|
|
|
|
DisplayAttributes = false;
|
2016-11-24 19:26:05 +03:00
|
|
|
|
NoGUI = false;
|
2014-01-13 21:26:37 +04:00
|
|
|
|
|
|
|
|
|
IsRunningOnMono = Type.GetType("Mono.Runtime") != null;
|
2010-10-31 18:02:13 +03:00
|
|
|
|
|
|
|
|
|
string[] args = Environment.GetCommandLineArgs();
|
|
|
|
|
List<string> arguments = new List<string>();
|
|
|
|
|
// Convert "--option:params" or "/option params" to "-option params"
|
|
|
|
|
foreach (var argument in args)
|
|
|
|
|
{
|
|
|
|
|
string command = null;
|
2010-11-01 21:50:54 +03:00
|
|
|
|
if (/*argument.StartsWith("/") ||*/ argument.StartsWith("-"))
|
2010-10-31 18:02:13 +03:00
|
|
|
|
command = argument.Substring(1);
|
|
|
|
|
else if (argument.StartsWith("--"))
|
|
|
|
|
command = argument.Substring(2);
|
|
|
|
|
if (!string.IsNullOrEmpty(command))
|
|
|
|
|
{
|
2010-11-01 21:50:54 +03:00
|
|
|
|
int indexOfColon = command.IndexOf(':');
|
2010-10-31 18:02:13 +03:00
|
|
|
|
if (indexOfColon > 0)
|
|
|
|
|
{
|
|
|
|
|
string parameter = command.Substring(indexOfColon + 1);
|
|
|
|
|
command = command.Substring(0, indexOfColon);
|
|
|
|
|
arguments.Add("-" + command);
|
|
|
|
|
arguments.Add(parameter);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
arguments.Add("-" + command);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
arguments.Add(argument);
|
|
|
|
|
}
|
|
|
|
|
Arguments = arguments.ToArray();
|
|
|
|
|
|
|
|
|
|
int currentArgument = 1;
|
|
|
|
|
while (currentArgument < arguments.Count)
|
|
|
|
|
{
|
|
|
|
|
string argument = arguments[currentArgument++];
|
|
|
|
|
if (string.Compare("-h", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
RequestHelp = true;
|
|
|
|
|
}
|
|
|
|
|
else if (string.Compare("-o", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (currentArgument < arguments.Count)
|
|
|
|
|
OutputFile = args[currentArgument++];
|
|
|
|
|
}
|
2010-11-01 03:10:19 +03:00
|
|
|
|
else if (string.Compare("-os", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
OutputOnStdOut = true;
|
|
|
|
|
if (currentArgument < arguments.Count)
|
|
|
|
|
OutputOnStdOutExtension = args[currentArgument++];
|
|
|
|
|
}
|
2010-10-31 18:02:13 +03:00
|
|
|
|
else if (string.Compare("-r", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (currentArgument < arguments.Count)
|
|
|
|
|
RootElements.Add(args[currentArgument++]);
|
|
|
|
|
}
|
2016-02-27 14:58:48 +03:00
|
|
|
|
else if (string.Compare("-e", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (currentArgument < arguments.Count)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ExpandLevel = int.Parse(args[currentArgument++]);
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(string.Compare("-d", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
ShowDocumentation = true;
|
|
|
|
|
}
|
2010-10-31 18:02:13 +03:00
|
|
|
|
else if (string.Compare("-z", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (currentArgument < arguments.Count)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Zoom = (float)int.Parse(args[currentArgument++]);
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-23 03:18:33 +04:00
|
|
|
|
else if (string.Compare("-y", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
ForceHugeImageGeneration = true;
|
|
|
|
|
}
|
2012-12-01 20:40:00 +04:00
|
|
|
|
else if (string.Compare("-u", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (currentArgument < arguments.Count)
|
|
|
|
|
Username = args[currentArgument++];
|
|
|
|
|
}
|
|
|
|
|
else if (string.Compare("-p", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (currentArgument < arguments.Count)
|
|
|
|
|
Password = args[currentArgument++];
|
|
|
|
|
}
|
2014-01-13 21:26:37 +04:00
|
|
|
|
else if (string.Compare("-f", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (currentArgument < arguments.Count)
|
|
|
|
|
{
|
|
|
|
|
string textOutputFields = args[currentArgument++];
|
|
|
|
|
foreach (string field in textOutputFields.Split(new char[] { ',' }))
|
|
|
|
|
TextOutputFields.Add(field.Trim());
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-10 20:14:01 +03:00
|
|
|
|
else if (string.Compare("-a", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
DisplayAttributes = true;
|
|
|
|
|
}
|
2016-11-24 19:26:05 +03:00
|
|
|
|
else if (string.Compare("-no-gui", argument, true) == 0)
|
|
|
|
|
{
|
|
|
|
|
NoGUI = true;
|
|
|
|
|
}
|
2014-01-13 21:26:37 +04:00
|
|
|
|
else
|
2010-10-31 18:02:13 +03:00
|
|
|
|
InputFile = argument;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|