Permalink
Browse files

add a silent install option via -s

  • Loading branch information...
1 parent 9f7e27a commit dcf6616c8c95bf62fc71048ea4e3f7c9ba43559a @mwrock committed Apr 21, 2012
Showing with 38 additions and 21 deletions.
  1. +38 −21 git-credential-winstore/Program.cs
@@ -24,7 +24,8 @@ class Program
static void Main(string[] args)
{
- TryLaunchDebugger(ref args);
+ TryLaunchDebugger(ref args);
+ if (TrySilentInstall(ref args)) { return; }
// Parse command
Func<IDictionary<string, string>, IEnumerable<Tuple<string, string>>> command = null;
@@ -61,6 +62,19 @@ private static void TryLaunchDebugger(ref string[] args)
Debugger.Launch();
args = args.Skip(1).ToArray();
}
+ }
+
+ private static bool TrySilentInstall(ref string[] args)
+ {
+ if (args.Length > 0 && args[0] == "-s")
+ {
+ Console.Out.WriteLine("Silently Installing...");
+ InstallTheApp(true);
+ args = args.Skip(1).ToArray();
+ return true;
+ }
+
+ return false;
}
private static void WriteGitParameters(IDictionary<string, string> response)
@@ -88,26 +102,29 @@ private static void WriteUsage()
Console.Error.WriteLine("If you see this. git-credential-winstore is correctly installed!");
Console.Error.WriteLine("This application is designed to be used by git as a credential helper and should not be invoked separately");
Console.Error.WriteLine("See the following link for more info: http://www.manpagez.com/man/1/git-credential-cache/");
- }
-
- private static void InstallTheApp()
- {
- if (MessageBox.Show("Do you want to install git-credential-winstore to prompt for passwords?",
- "Installing git-credential-winstore", MessageBoxButtons.YesNo) != DialogResult.Yes)
- {
- return;
- }
-
- var target = new DirectoryInfo(Environment.ExpandEnvironmentVariables(@"%AppData%\GitCredStore"));
- if (!target.Exists)
- {
- target.Create();
- }
-
- var dest = new FileInfo(Environment.ExpandEnvironmentVariables(@"%AppData%\GitCredStore\git-credential-winstore.exe"));
- File.Copy(Assembly.GetExecutingAssembly().Location, dest.FullName, true);
-
- Process.Start("git", "config --global credential.helper !~/AppData/Roaming/GitCredStore/git-credential-winstore");
+ }
+
+ private static void InstallTheApp(bool silent = false)
+ {
+ if(!silent)
+ {
+ if (MessageBox.Show("Do you want to install git-credential-winstore to prompt for passwords?",
+ "Installing git-credential-winstore", MessageBoxButtons.YesNo) != DialogResult.Yes)
+ {
+ return;
+ }
+ }
+
+ var target = new DirectoryInfo(Environment.ExpandEnvironmentVariables(@"%AppData%\GitCredStore"));
+ if (!target.Exists)
+ {
+ target.Create();
+ }
+
+ var dest = new FileInfo(Environment.ExpandEnvironmentVariables(@"%AppData%\GitCredStore\git-credential-winstore.exe"));
+ File.Copy(Assembly.GetExecutingAssembly().Location, dest.FullName, true);
+
+ Process.Start("git", "config --global credential.helper !~/AppData/Roaming/GitCredStore/git-credential-winstore");
}
static IEnumerable<Tuple<string, string>> GetCommand(IDictionary<string, string> args)

0 comments on commit dcf6616

Please sign in to comment.