MCPcopy Create free account
hub / github.com/brocode/fw / create_tag

Function create_tag

src/tag/mod.rs:67–92  ·  view source on GitHub ↗
(
	maybe_config: Result<Config, AppError>,
	tag_name: String,
	after_workon: Option<String>,
	after_clone: Option<String>,
	priority: Option<u8>,
	tag_workspace: Option<String>,
)

Source from the content-addressed store, hash-verified

65}
66
67pub fn create_tag(
68 maybe_config: Result<Config, AppError>,
69 tag_name: String,
70 after_workon: Option<String>,
71 after_clone: Option<String>,
72 priority: Option<u8>,
73 tag_workspace: Option<String>,
74) -> Result<(), AppError> {
75 let config: Config = maybe_config?;
76 let tags: BTreeMap<String, Tag> = config.settings.tags.unwrap_or_default();
77
78 if tags.contains_key(&tag_name) {
79 Err(AppError::UserError(format!("Tag {} already exists, not gonna overwrite it for you", tag_name)))
80 } else {
81 let new_tag = Tag {
82 after_clone,
83 after_workon,
84 priority,
85 workspace: tag_workspace,
86 default: None,
87 tag_config_path: "default".to_string(),
88 };
89 config::write_tag(&tag_name, &new_tag)?;
90 Ok(())
91 }
92}
93
94pub fn inspect_tag(maybe_config: Result<Config, AppError>, tag_name: &str) -> Result<(), AppError> {
95 let config: Config = maybe_config?;

Callers 1

execute_tag_subcommandFunction · 0.85

Calls 1

write_tagFunction · 0.85

Tested by

no test coverage detected