auto cred = getCredPlainText("user", "pass"); switch (cred.credType) with (GitCredType) { case plaintext: { version (GIT_SSH) { static assert(0, "dlibgit does not support SSH yet."); // throw when trying to cast to an inappropriate type assertThrown!GitException(cred.get!passphrase); // ditto assertThrown!GitException(cred.get!GitCred_KeyFilePassPhrase); } // use enum for the get template auto cred1 = cred.get!plaintext; assert(cred1.username == "user"); assert(cred1.password == "pass"); // or use a type auto cred2 = cred.get!GitCred_PlainText; assert(cred2.username == "user"); assert(cred2.password == "pass"); break; } default: assert(0, text(cred.credType)); }
Creates a new plain-text username and password credential object. The supplied credential parameter will be internally duplicated.