MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / execute_remove

Method execute_remove

crates/chat-cli/src/cli/chat/cli/prompts.rs:1816–1972  ·  view source on GitHub ↗
(
        os: &Os,
        session: &mut ChatSession,
        name: String,
        global: bool,
    )

Source from the content-addressed store, hash-verified

1814 }
1815
1816 async fn execute_remove(
1817 os: &Os,
1818 session: &mut ChatSession,
1819 name: String,
1820 global: bool,
1821 ) -> Result<ChatState, ChatError> {
1822 let prompts = Prompts::new(&name, os).map_err(|e| ChatError::Custom(e.to_string().into()))?;
1823 let (local_exists, global_exists) = (prompts.local.exists(), prompts.global.exists());
1824
1825 // Find the target prompt to remove
1826 let target_prompt = if global {
1827 if !global_exists {
1828 queue!(
1829 session.stderr,
1830 style::Print("\n"),
1831 StyledText::warning_fg(),
1832 style::Print("Global prompt "),
1833 StyledText::brand_fg(),
1834 style::Print(&name),
1835 StyledText::warning_fg(),
1836 style::Print(" not found.\n"),
1837 StyledText::reset(),
1838 )?;
1839 return Ok(ChatState::PromptUser {
1840 skip_printing_tools: true,
1841 });
1842 }
1843 &prompts.global
1844 } else if local_exists {
1845 &prompts.local
1846 } else if global_exists {
1847 queue!(
1848 session.stderr,
1849 style::Print("\n"),
1850 StyledText::warning_fg(),
1851 style::Print("Local prompt "),
1852 StyledText::brand_fg(),
1853 style::Print(&name),
1854 StyledText::warning_fg(),
1855 style::Print(" not found, but global version exists.\n"),
1856 style::Print("Use "),
1857 StyledText::brand_fg(),
1858 style::Print("/prompts remove "),
1859 style::Print(&name),
1860 style::Print(" --global"),
1861 StyledText::warning_fg(),
1862 style::Print(" to remove the global version.\n"),
1863 StyledText::reset(),
1864 )?;
1865 return Ok(ChatState::PromptUser {
1866 skip_printing_tools: true,
1867 });
1868 } else {
1869 queue!(
1870 session.stderr,
1871 style::Print("\n"),
1872 StyledText::warning_fg(),
1873 style::Print("Prompt "),

Callers

nothing calls this directly

Calls 5

CustomClass · 0.85
inputFunction · 0.85
to_stringMethod · 0.80
existsMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected