Ask for account password if -password is omitted from command line.

pull/8/head
Scott Ehlert 14 years ago
parent 9d586b5e95
commit 44ff453193

@ -120,6 +120,13 @@ namespace DepotDownloader
bool bNoExclude = HasParameter( args, "-no-exclude" );
bool bAllPlatforms = HasParameter( args, "-all-platforms" );
if (username != null && password == null)
{
Console.Write( "Enter account password: " );
password = Util.ReadPassword();
Console.WriteLine();
}
if ( !bGameserver && !bApp )
{
ContentDownloader.Download( depotId, depotVersion, cellId, username, password, !bDebot, false, false, installDir, files );

@ -64,5 +64,30 @@ namespace DepotDownloader
return bytes;
}
public static string ReadPassword()
{
ConsoleKeyInfo keyInfo;
StringBuilder password = new StringBuilder();
do
{
keyInfo = Console.ReadKey( true );
if ( keyInfo.Key == ConsoleKey.Backspace )
{
if ( password.Length > 0 )
password.Remove( password.Length - 1, 1 );
continue;
}
/* Printable ASCII characters only */
char c = keyInfo.KeyChar;
if ( c >= ' ' && c <= '~' )
password.Append( c );
} while ( keyInfo.Key != ConsoleKey.Enter );
return password.ToString();
}
}
}

Loading…
Cancel
Save