-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Internal refactoring - First search in KeePass on title "git [...lowercase last part of directory...][...lowercase computername...]"
- Loading branch information
1 parent
213af08
commit 7e986f4
Showing
15 changed files
with
396 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Text; | ||
|
||
namespace git_credential_keepasscommand | ||
{ | ||
public class NameValuePairs | ||
{ | ||
public ReadOnlyCollection<NameValue> pairs { get; } | ||
|
||
public NameValuePairs(ReadOnlyCollection<NameValue> pairs) | ||
{ | ||
this.pairs = pairs; | ||
} | ||
|
||
public static NameValuePairs fromStdin() | ||
{ | ||
//stdin contains input as name = value pairs. | ||
var input = new List<NameValue>(); | ||
|
||
string stdin = String.Empty; | ||
try | ||
{ | ||
var isKeyAvailable = Console.KeyAvailable; | ||
} | ||
catch (InvalidOperationException) | ||
{ | ||
//On a redirected stdin, there can't be a KeyAvailable | ||
stdin = Console.In.ReadToEnd(); | ||
} | ||
|
||
foreach (var line in stdin.Split('\n')) | ||
{ | ||
var pos_is = line.IndexOf('='); | ||
if (pos_is >= 0) | ||
{ | ||
string name = String.Empty; | ||
string value = String.Empty; | ||
|
||
if (pos_is > 0) name = line.Substring(0, pos_is).Trim(); | ||
if (pos_is + 1 < line.Length) value = line.Substring(pos_is + 1).Trim(); | ||
|
||
input.Add(new NameValue(name, value)); | ||
} | ||
} | ||
|
||
return new NameValuePairs(input.AsReadOnly()); | ||
} | ||
} | ||
} |
Oops, something went wrong.