repo_cli/query/
mod.rs

1use serde::{Deserialize, Serialize};
2use url::Url;
3
4/// Represents a input url from the user.
5///
6/// Available patterns are:
7///
8/// * `<scheme>://[<username>[:<password>]@]<host>/<path-to-repo>.git`
9///   - Available schemes are: `http[s]`, `ssh` and `git`.
10///   - Example: https://github.com/user/repo
11/// * `<username>@<host>:<path-to-repo>`
12///   - Equivalent to `ssh://<username>@<host>/<path-to-repo>.git`
13/// * `<username>@<host>:<path-to-repo>`
14///   - Equivalent to `ssh://<username>@<host>/<path-to-repo>.git`
15/// * `<path-to-repo>`
16#[derive(Debug, Serialize, Deserialize)]
17pub enum Query {
18    Url(Url),
19    Scp(ScpPath),
20    Abbrev(AbbrevUrl),
21}
22
23#[derive(Debug, Serialize, Deserialize)]
24pub struct ScpPath {
25    pub host: String,
26    pub username: String,
27    pub path: String,
28}
29
30#[derive(Debug, Serialize, Deserialize)]
31pub struct AbbrevUrl {
32    pub username: String,
33    pub path: String,
34}
35
36#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
37pub enum Scheme {
38    #[serde(rename = "http")]
39    Http,
40    #[serde(rename = "https")]
41    Https,
42    #[serde(rename = "git")]
43    Git,
44    #[serde(rename = "ssh")]
45    Ssh,
46}
47
48mod abbrev;
49mod inner;
50mod scheme;
51mod scp;