From 365f8d7f30bf2cef6d4e6bf4c8f5a306aaf3a899 Mon Sep 17 00:00:00 2001 From: "kenneth.skovhede@gmail.com" Date: Sun, 22 Mar 2009 22:55:04 +0000 Subject: [PATCH] Improved the usage dialog greatly, and added some missing options. Still needs to describe the filter system. git-svn-id: https://duplicati.googlecode.com/svn/trunk@129 59da171f-624f-0410-aa54-27559c288bec --- Duplicati/CommandLine/Program.cs | 32 +++- .../BackendInterface/CommandLineArgument.cs | 8 + .../BackendInterface/ICommandLineArgument.cs | 1 + Duplicati/Library/Backend/FTP/FTPBackend.cs | 2 +- Duplicati/Library/Backend/File/FileBackend.cs | 2 +- Duplicati/Library/Backend/S3/S3Backend.cs | 2 +- Duplicati/Library/Backend/SSH/SSHBackend.cs | 2 +- .../Duplicati.Library.Backend.WEBDAV.csproj | 2 +- Duplicati/Library/Backend/WEBDAV/WEBDAV.cs | 2 +- Duplicati/Library/Main/FilenameStrategy.cs | 8 +- Duplicati/Library/Main/Interface.cs | 163 ++++++++---------- Duplicati/Library/Main/Options.cs | 141 ++++++++++++++- 12 files changed, 259 insertions(+), 106 deletions(-) diff --git a/Duplicati/CommandLine/Program.cs b/Duplicati/CommandLine/Program.cs index a00bb531f..e397bea32 100644 --- a/Duplicati/CommandLine/Program.cs +++ b/Duplicati/CommandLine/Program.cs @@ -305,7 +305,30 @@ namespace Duplicati.CommandLine lines.Add(""); foreach (string s in lines) - Console.WriteLine(s); + { + if (string.IsNullOrEmpty(s)) + { + Console.WriteLine(); + continue; + } + + string c = s; + + string leadingSpaces = ""; + while (c.Length > 0 && c.StartsWith(" ")) + { + leadingSpaces += " "; + c = c.Remove(0, 1); + } + + while (c.Length > 0) + { + int len = Math.Min(Console.WindowWidth - 2, leadingSpaces.Length + c.Length); + len -= leadingSpaces.Length; + Console.WriteLine(leadingSpaces + c.Substring(0, len)); + c = c.Remove(0, len); + } + } } @@ -315,6 +338,13 @@ namespace Duplicati.CommandLine lines.Add(" " + arg.LongDescription); if (arg.Aliases != null && arg.Aliases.Length > 0) lines.Add(" aliases: --" + string.Join(", --", arg.Aliases)); + + if (arg.ValidValues != null && arg.ValidValues.Length > 0) + lines.Add(" values: " + string.Join(", ", arg.ValidValues)); + + if (!string.IsNullOrEmpty(arg.DefaultValue)) + lines.Add(" default value: " + arg.DefaultValue); + } } } diff --git a/Duplicati/Library/Backend/BackendInterface/CommandLineArgument.cs b/Duplicati/Library/Backend/BackendInterface/CommandLineArgument.cs index 916609980..53004bb3f 100644 --- a/Duplicati/Library/Backend/BackendInterface/CommandLineArgument.cs +++ b/Duplicati/Library/Backend/BackendInterface/CommandLineArgument.cs @@ -123,6 +123,14 @@ namespace Duplicati.Library.Backend set { m_longDescription = value; } } + /// + /// The default value for the parameter + /// + public string DefaultValue + { + get { return m_defaultValue; } + set { m_defaultValue = value; } + } /// /// Creates a new CommandLineArgument instance diff --git a/Duplicati/Library/Backend/BackendInterface/ICommandLineArgument.cs b/Duplicati/Library/Backend/BackendInterface/ICommandLineArgument.cs index fd6ca86f8..30e189392 100644 --- a/Duplicati/Library/Backend/BackendInterface/ICommandLineArgument.cs +++ b/Duplicati/Library/Backend/BackendInterface/ICommandLineArgument.cs @@ -28,5 +28,6 @@ namespace Duplicati.Library.Backend string ShortDescription { get; set; } CommandLineArgument.ArgumentType Type { get; set; } string[] ValidValues { get; set; } + string DefaultValue { get; set; } } } diff --git a/Duplicati/Library/Backend/FTP/FTPBackend.cs b/Duplicati/Library/Backend/FTP/FTPBackend.cs index d1dce8586..f7ff8143a 100644 --- a/Duplicati/Library/Backend/FTP/FTPBackend.cs +++ b/Duplicati/Library/Backend/FTP/FTPBackend.cs @@ -206,7 +206,7 @@ namespace Duplicati.Library.Backend { get { - return "This backend can read and write data to an FTP based backend.\nAllowed formats are \"ftp://hostname/folder\" or \"ftp://username:password@hostname/folder\""; + return "This backend can read and write data to an FTP based backend. Allowed formats are \"ftp://hostname/folder\" or \"ftp://username:password@hostname/folder\""; } } diff --git a/Duplicati/Library/Backend/File/FileBackend.cs b/Duplicati/Library/Backend/File/FileBackend.cs index 2be09763b..f809642ad 100644 --- a/Duplicati/Library/Backend/File/FileBackend.cs +++ b/Duplicati/Library/Backend/File/FileBackend.cs @@ -151,7 +151,7 @@ namespace Duplicati.Library.Backend { get { - return "This backend can read and write data to an file based backend.\nAllowed formats are \"file://hostname/folder\" or \"file://username:password@hostname/folder\"\nYou may supply UNC paths (eg: \"file://\\\\server\\folder\") or local paths (eg: (win) \"file://c:\\folder\", (linux) \"file:///usr/pub/files\")."; + return "This backend can read and write data to an file based backend. Allowed formats are \"file://hostname/folder\" or \"file://username:password@hostname/folder\". You may supply UNC paths (eg: \"file://\\\\server\\folder\") or local paths (eg: (win) \"file://c:\\folder\", (linux) \"file:///usr/pub/files\")."; } } diff --git a/Duplicati/Library/Backend/S3/S3Backend.cs b/Duplicati/Library/Backend/S3/S3Backend.cs index 4acc6173a..c7299f2a4 100644 --- a/Duplicati/Library/Backend/S3/S3Backend.cs +++ b/Duplicati/Library/Backend/S3/S3Backend.cs @@ -244,7 +244,7 @@ namespace Duplicati.Library.Backend { get { - return "This backend can read and write data to an Amazon S3 based backend.\nAllowed formats are \"s3://bucketname/prefix\" or \"s3://aws_id:aws_key@bucketname/prefix\".\nNote that if you AWS ID or Key contains either \":\", \"/\" or \"@\" you cannot use the second form, but must supply them through arguments."; + return "This backend can read and write data to an Amazon S3 based backend. Allowed formats are \"s3://bucketname/prefix\" or \"s3://aws_id:aws_key@bucketname/prefix\". Note that if you AWS ID or Key contains either \":\", \"/\" or \"@\" you cannot use the second form, but must supply them through arguments."; } } diff --git a/Duplicati/Library/Backend/SSH/SSHBackend.cs b/Duplicati/Library/Backend/SSH/SSHBackend.cs index 43b8b1eca..e30711545 100644 --- a/Duplicati/Library/Backend/SSH/SSHBackend.cs +++ b/Duplicati/Library/Backend/SSH/SSHBackend.cs @@ -197,7 +197,7 @@ namespace Duplicati.Library.Backend { get { - return "This backend can read and write data to an SSH based backend, using SCP and SFTP.\nAllowed formats are \"ssh://hostname/folder\" or \"ssh://username:password@hostname/folder\"\nNOTE: This backend does not support throttling uploads or downloads."; + return "This backend can read and write data to an SSH based backend, using SCP and SFTP. Allowed formats are \"ssh://hostname/folder\" or \"ssh://username:password@hostname/folder\". NOTE: This backend does not support throttling uploads or downloads, and requires that sftp and scp are installed (using putty for windows)."; } } diff --git a/Duplicati/Library/Backend/WEBDAV/Duplicati.Library.Backend.WEBDAV.csproj b/Duplicati/Library/Backend/WEBDAV/Duplicati.Library.Backend.WEBDAV.csproj index cfea995e1..b817331bd 100644 --- a/Duplicati/Library/Backend/WEBDAV/Duplicati.Library.Backend.WEBDAV.csproj +++ b/Duplicati/Library/Backend/WEBDAV/Duplicati.Library.Backend.WEBDAV.csproj @@ -7,7 +7,7 @@ {BAE27510-8B5D-44B2-B33E-372A98908041} Library Properties - Duplicati.Library.Backend.WEBDAV + Duplicati.Library.Backend Duplicati.Library.Backend.WEBDAV diff --git a/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs b/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs index 566137419..7f7bc35bb 100644 --- a/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs +++ b/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs @@ -174,7 +174,7 @@ namespace Duplicati.Library.Backend public string Description { - get { return "Supports connections to a WEBDAV enabled web server"; } + get { return "Supports connections to a WEBDAV enabled web server, using the HTTP protocol. Allowed formats are \"webdav://hostname/folder\" or \"webdav://username:password@hostname/folder\"."; } } #endregion diff --git a/Duplicati/Library/Main/FilenameStrategy.cs b/Duplicati/Library/Main/FilenameStrategy.cs index 991cbfaff..725260012 100644 --- a/Duplicati/Library/Main/FilenameStrategy.cs +++ b/Duplicati/Library/Main/FilenameStrategy.cs @@ -47,12 +47,8 @@ namespace Duplicati.Library.Main m_filenameRegExp = new Regex(@"(?" + Regex.Escape(m_prefix) + @")\-(?(full|inc))\-(?(content|signature|manifest))\.(? public bool Force { get { return GetBool("force"); } } + /// + /// Gets the folder where temporary files are stored + /// + public string TempDir + { + get + { + if (!m_options.ContainsKey("tempdir") || string.IsNullOrEmpty(m_options["tempdir"])) + return null; + else + return m_options["tempdir"]; + } + } + + /// + /// Gets the process priority + /// + public string ThreadPriority + { + get + { + if (!m_options.ContainsKey("thread-priority") || string.IsNullOrEmpty(m_options["thread-priority"])) + return null; + else + return m_options["thread-priority"]; + } + } + + /// + /// A value indicating if file deletes are forced + /// + public bool UseShortFilenames { get { return GetBool("short-filenames"); } } + + /// + /// Gets the backup prefix + /// + public string BackupPrefix + { + get + { + if (!m_options.ContainsKey("backup-prefix") || string.IsNullOrEmpty(m_options["backup-prefix"])) + return this.UseShortFilenames ? "dpl" : "duplicati"; + else + return m_options["backup-prefix"]; + } + } + + /// + /// Gets the process priority + /// + public string TimeSeperatorChar + { + get + { + if (!m_options.ContainsKey("time-separator") || string.IsNullOrEmpty(m_options["time-separator"])) + return ":"; + else + return m_options["time-separator"]; + } + } + + + /// + /// Gets the filter used to include or exclude files + /// + public Core.FilenameFilter Filter + { + get + { + if (m_options.ContainsKey("filter")) + return new Duplicati.Library.Core.FilenameFilter(Core.FilenameFilter.DecodeFilter(m_options["filter"])); + else + return new Duplicati.Library.Core.FilenameFilter(new List>()); + } + } + + /// + /// Returns a value indiciating if a filter is specified + /// + public bool HasFilter { get { return m_options.ContainsKey("filter"); } } + + /// + /// Gets the number of old backups to keep + /// + public int RemoveAllButNFull + { + get + { + if (!m_options.ContainsKey("remove-all-but-n-full")) + throw new Exception("No count given for \"Remove All But N Full\""); + + int x = int.Parse(m_options["remove-all-but-n-full"]); + if (x < 0) + throw new Exception("Invalid count for remove-all-but-n-full"); + + return x; + } + } + + /// + /// Gets the timelimit for removal + /// + public DateTime RemoveOlderThan + { + get + { + if (!m_options.ContainsKey("remove-older-than")) + throw new Exception("No count given for \"Remove Older Than\""); + + return Core.Timeparser.ParseTimeInterval(m_options["remove-older-than"], DateTime.Now, true); + } + } + private bool GetBool(string name) { if (!m_options.ContainsKey(name))