getCredPlainText

Creates a new plain-text username and password credential object. The supplied credential parameter will be internally duplicated.

getCredPlainText
(
string username
,
string password
)

Examples

1 auto cred = getCredPlainText("user", "pass");
2 
3 switch (cred.credType) with (GitCredType)
4 {
5     case plaintext:
6     {
7         version (GIT_SSH)
8         {
9             static assert(0, "dlibgit does not support SSH yet.");
10 
11             // throw when trying to cast to an inappropriate type
12             assertThrown!GitException(cred.get!passphrase);
13 
14             // ditto
15             assertThrown!GitException(cred.get!GitCred_KeyFilePassPhrase);
16         }
17 
18         // use enum for the get template
19         auto cred1 = cred.get!plaintext;
20         assert(cred1.username == "user");
21         assert(cred1.password == "pass");
22 
23         // or use a type
24         auto cred2 = cred.get!GitCred_PlainText;
25         assert(cred2.username == "user");
26         assert(cred2.password == "pass");
27 
28         break;
29     }
30 
31     default: assert(0, text(cred.credType));
32 }

Meta