MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / get_message

Method get_message

atomic-cli/src/commands/record/builder.rs:115–149  ·  view source on GitHub ↗

Get the commit message, potentially from editor.

(&self)

Source from the content-addressed store, hash-verified

113
114 /// Get the commit message, potentially from editor.
115 pub(super) fn get_message(&self) -> CliResult<String> {
116 // If message was provided, use it
117 if let Some(ref msg) = self.message {
118 return Ok(msg.clone());
119 }
120
121 // If edit flag is set or we're in a terminal without a message
122 if self.edit {
123 return self.get_message_from_editor();
124 }
125
126 // Check if stdin is a terminal
127 if is_terminal() {
128 // Interactive mode - prompt for message
129 print!("Enter commit message (empty line to cancel): ");
130 std::io::stdout().flush().map_err(|e| {
131 CliError::Internal(anyhow::anyhow!("Failed to flush stdout: {}", e))
132 })?;
133
134 let mut message = String::new();
135 std::io::stdin().read_line(&mut message).map_err(|e| {
136 CliError::Internal(anyhow::anyhow!("Failed to read message: {}", e))
137 })?;
138
139 let message = message.trim();
140 if message.is_empty() {
141 return Err(CliError::Cancelled);
142 }
143
144 Ok(message.to_string())
145 } else {
146 // Non-interactive mode - use default message
147 Ok("No message provided".to_string())
148 }
149 }
150
151 /// Open an editor to get the commit message.
152 pub(super) fn get_message_from_editor(&self) -> CliResult<String> {

Callers 1

runMethod · 0.45

Calls 5

is_terminalFunction · 0.85
cloneMethod · 0.45
flushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected