Skip to content

Commit

Permalink
Merge pull request #14 from RounakJoshi09/rounakj/gitlab
Browse files Browse the repository at this point in the history
Load Template from Gitlab Functionality Added
  • Loading branch information
cophilot authored Nov 3, 2024
2 parents a5959bd + 94b7250 commit c0a3b2b
Show file tree
Hide file tree
Showing 8 changed files with 406 additions and 42 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
ideas.md
templify-example
dev/
tpy-test-dir
tpy-test-dir
command.md
40 changes: 40 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ reqwest = { version = "0.12", features = ["blocking", "json"] }
self-replace = "1.3.6"
serde_json = "1.0.1"
chrono = "0.4.19"
base64 = "0.21.7"
regex = "1.11.1"
9 changes: 2 additions & 7 deletions src/commands/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) fn definition() -> Command {
"url".to_string(),
0,
true,
"The url of the github repository.".to_string(),
"The url of the github or gitlab repository.".to_string(),
));

load_command.add_flag(Flag::new_bool_flag(
Expand Down Expand Up @@ -46,12 +46,6 @@ pub(crate) fn load(command: &Command) -> Status {
}

let url = command.get_argument("url").value.clone();
if !url.starts_with("https://github.com") {
return Status::error(format!(
"Invalid url: {}\nOnly templates from GitHub are supported at the moment.",
url
));
}

let load_template = command.get_bool_flag("template");
if load_template {
Expand All @@ -61,6 +55,7 @@ pub(crate) fn load(command: &Command) -> Status {
format!(".templates/{}", name).as_str(),
url.as_str(),
command.get_bool_flag("force"),
None,
);
if !st.is_ok {
return st;
Expand Down
6 changes: 6 additions & 0 deletions src/types/load_types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// This enum is used to define type of URL (.i.e.. GitHub, GitLab)
#[derive(Clone)]
pub(crate) enum URLType {
GitHub,
GitLab,
}
1 change: 1 addition & 0 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod argument;
pub mod command;
pub mod flag;
pub mod global_flag;
pub mod load_types;
pub mod status;
pub mod template_meta;
pub mod var_placeholder;
Expand Down
Loading

0 comments on commit c0a3b2b

Please sign in to comment.