-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
86 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Threading.Tasks; | ||
using CommandLine; | ||
using SeafClient; | ||
|
||
namespace SeafileCli.Argparse | ||
{ | ||
public class AuthorizationOptions : CommonOptions | ||
{ | ||
[Option('u', "username", HelpText = "The username used for authorization.")] | ||
public string Username { get; set; } | ||
|
||
[Option('p', "password", HelpText = "The password used for authorization.")] | ||
public string Password { get; set; } | ||
|
||
[Option('t', "token", | ||
HelpText = | ||
"The API Token used for authorization. If the token is used, username and password are not required.")] | ||
public string Token { get; set; } | ||
|
||
public async Task<SeafSession> GetSession() | ||
{ | ||
if (!string.IsNullOrEmpty(Token)) | ||
{ | ||
return await SeafSession.FromToken(ServerUri, Token); | ||
} | ||
|
||
return await SeafSession.Establish(ServerUri, Username, Password.ToCharArray()); | ||
} | ||
} | ||
} |
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
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
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,30 @@ | ||
using System; | ||
using SeafClient; | ||
using SeafileCli.Argparse; | ||
|
||
namespace SeafileCli.VerbHandler | ||
{ | ||
/// <summary> | ||
/// Retrieves the server information and prints it on the console. | ||
/// </summary> | ||
public class ServerInfoHandler : IVerbHandler | ||
{ | ||
private readonly CommonOptions _options; | ||
|
||
public ServerInfoHandler(CommonOptions options) | ||
{ | ||
_options = options; | ||
} | ||
|
||
public void Run() | ||
{ | ||
var serverInfo = SeafSession.GetServerInfo(_options.ServerUri).Result; | ||
Console.WriteLine($"Version: {serverInfo.Version}"); | ||
Console.WriteLine("Features:"); | ||
foreach (var feature in serverInfo.Features) | ||
{ | ||
Console.WriteLine($"- {feature}"); | ||
} | ||
} | ||
} | ||
} |
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