summaryrefslogtreecommitdiff
path: root/src/appimage.rs
blob: c3f61b1c953cf7dd2be66be4f91ee17cf44abf94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

use crate::InstallArgs;

#[derive(Debug, Serialize, Deserialize)]
pub struct AppImage {
    pub file_path: PathBuf,
    pub executable: String,
    pub source: Source,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Source {
    pub identifier: String,
    pub meta: SourceMetadata,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct SourceMetadata {
    pub url: String,
}

impl AppImage {
    pub fn new(options: &InstallArgs) -> Self {
        Self {
            file_path: PathBuf::new(),
            executable: options
                .executable
                .as_ref()
                .unwrap_or(&options.appname)
                .to_string(),
            source: Source {
                identifier: if options.github {
                    "git.github".to_string()
                } else {
                    "raw_url".to_string()
                },
                meta: SourceMetadata {
                    url: options.from.clone(),
                },
            },
        }
    }
}