use std::fmt::{Display, Formatter, Result};

pub struct GitRepo {}

impl GitRepo {

    pub fn new() -> GitRepo {
        GitRepo{}
    }

    pub async fn browse(&self, commit : &GitCommit, dir: &GitBrowseDir) -> Vec<GitBrowseEntry> {
        vec!(GitBrowseEntry::EGitDir(GitBrowseDir("src/".to_string())), GitBrowseEntry::EGitFile(GitBrowseFile("pom.xml".to_string())))
    }

}

#[derive(Debug)]
pub struct GitCommit (String);

impl GitCommit {
    pub fn new(s : String) -> GitCommit {
        GitCommit(s)
    }
}

impl Display for GitCommit {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        write!(f, "{}", self.0)
    }
}

#[derive(Debug)]
pub struct GitBrowseFile (String);
#[derive(Debug)]
pub struct GitBrowseDir (String);

impl GitBrowseDir {
    pub fn new(s : String) -> GitBrowseDir {
        GitBrowseDir(s)
    }
}

impl Display for GitBrowseFile {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        write!(f, "{}", self.0)
    }
}

impl Display for GitBrowseDir {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        write!(f, "{}", self.0)
    }
}

#[derive(Debug)]
pub enum GitBrowseEntry {
    EGitFile(GitBrowseFile),
    EGitDir(GitBrowseDir)
}

impl Display for GitBrowseEntry {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        match self {
            GitBrowseEntry::EGitFile(file) => {write!(f, "{}", file)}
            GitBrowseEntry::EGitDir(dir) => {write!(f, "{}", dir)}
        }
    }
}