mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CmdContext: Add helpful hint to output when setting context
This commit is contained in:
parent
e2f35a1a06
commit
1a0f479394
11 changed files with 16 additions and 16 deletions
|
@ -1017,12 +1017,12 @@ result affected by the current active context.
|
||||||
2 1d Home Clean the dishes 1.14
|
2 1d Home Clean the dishes 1.14
|
||||||
|
|
||||||
$ task context home
|
$ task context home
|
||||||
Context 'home' applied.
|
Context 'home' set. Use 'task context none' to remove.
|
||||||
|
|
||||||
$ task list
|
$ task list
|
||||||
ID Age Project Description Urg
|
ID Age Project Description Urg
|
||||||
2 1d Home Clean the dishes 1.14
|
2 1d Home Clean the dishes 1.14
|
||||||
Context 'home' applied.
|
Context 'home' set. Use 'task context none' to remove.
|
||||||
|
|
||||||
As seen in the example above, context is applied by specifying its name to the
|
As seen in the example above, context is applied by specifying its name to the
|
||||||
"context" command. To change the currently applied context, just pass the
|
"context" command. To change the currently applied context, just pass the
|
||||||
|
|
|
@ -414,7 +414,7 @@ void CLI::addContextFilter ()
|
||||||
{
|
{
|
||||||
addRawFilter("( " + contextFilter + " )");
|
addRawFilter("( " + contextFilter + " )");
|
||||||
if (context.verbose ("context"))
|
if (context.verbose ("context"))
|
||||||
context.footnote (format("Context '{1}' applied.", contextName));
|
context.footnote (format("Context '{1}' set. Use 'task context none' to remove.", contextName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -570,7 +570,7 @@
|
||||||
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
||||||
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
||||||
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
||||||
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' applied."
|
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' set. Use 'task context none' to remove."
|
||||||
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
||||||
|
|
|
@ -570,7 +570,7 @@
|
||||||
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
||||||
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
||||||
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
||||||
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' applied."
|
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' set. Use 'task context none' to remove."
|
||||||
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
||||||
|
|
|
@ -570,7 +570,7 @@
|
||||||
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
||||||
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
||||||
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
||||||
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' applied."
|
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' set. Use 'task context none' to remove."
|
||||||
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
||||||
|
|
|
@ -579,7 +579,7 @@
|
||||||
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
||||||
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
||||||
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
||||||
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' applied."
|
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' set. Use 'task context none' to remove."
|
||||||
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
||||||
|
|
|
@ -570,7 +570,7 @@
|
||||||
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
||||||
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
||||||
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
||||||
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' applied."
|
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' set. Use 'task context none' to remove."
|
||||||
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
||||||
|
|
|
@ -569,7 +569,7 @@
|
||||||
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
||||||
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
||||||
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
||||||
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' applied."
|
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' set. Use 'task context none' to remove."
|
||||||
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
||||||
|
|
|
@ -570,7 +570,7 @@
|
||||||
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
||||||
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
||||||
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
||||||
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' applied."
|
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' set. Use 'task context none' to remove."
|
||||||
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
||||||
|
|
|
@ -570,7 +570,7 @@
|
||||||
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
||||||
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
||||||
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
||||||
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' applied."
|
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' set. Use 'task context none' to remove."
|
||||||
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
||||||
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
||||||
|
|
|
@ -182,7 +182,7 @@ class ContextManagementTest(TestCase):
|
||||||
self.t(('context', 'define', 'home', '+home'))[1]
|
self.t(('context', 'define', 'home', '+home'))[1]
|
||||||
|
|
||||||
output = self.t(('context', 'home'))[1]
|
output = self.t(('context', 'home'))[1]
|
||||||
self.assertIn("Context 'home' applied.", output)
|
self.assertIn("Context 'home' set.", output)
|
||||||
self.assertIn("context=home\n", self.t.taskrc_content)
|
self.assertIn("context=home\n", self.t.taskrc_content)
|
||||||
|
|
||||||
def test_context_resetting(self):
|
def test_context_resetting(self):
|
||||||
|
@ -195,7 +195,7 @@ class ContextManagementTest(TestCase):
|
||||||
|
|
||||||
self.t(('context', 'home'))[1]
|
self.t(('context', 'home'))[1]
|
||||||
output = self.t(('context', 'home'))[1]
|
output = self.t(('context', 'home'))[1]
|
||||||
self.assertIn("Context 'home' applied.", output)
|
self.assertIn("Context 'home' set.", output)
|
||||||
|
|
||||||
contains_home = lambda line: line == "context=home\n"
|
contains_home = lambda line: line == "context=home\n"
|
||||||
self.assertEqual(len(filter(contains_home, self.t.taskrc_content)), 1)
|
self.assertEqual(len(filter(contains_home, self.t.taskrc_content)), 1)
|
||||||
|
@ -213,20 +213,20 @@ class ContextManagementTest(TestCase):
|
||||||
|
|
||||||
# Switch to home context
|
# Switch to home context
|
||||||
output = self.t(('context', 'home'))[1]
|
output = self.t(('context', 'home'))[1]
|
||||||
self.assertIn("Context 'home' applied.", output)
|
self.assertIn("Context 'home' set.", output)
|
||||||
|
|
||||||
self.assertEqual(len(filter(contains_home, self.t.taskrc_content)), 1)
|
self.assertEqual(len(filter(contains_home, self.t.taskrc_content)), 1)
|
||||||
|
|
||||||
# Switch to work context
|
# Switch to work context
|
||||||
output = self.t(('context', 'work'))[1]
|
output = self.t(('context', 'work'))[1]
|
||||||
self.assertIn("Context 'work' applied.", output)
|
self.assertIn("Context 'work' set.", output)
|
||||||
|
|
||||||
self.assertNotIn("context=home\n", self.t.taskrc_content)
|
self.assertNotIn("context=home\n", self.t.taskrc_content)
|
||||||
self.assertEqual(len(filter(contains_work, self.t.taskrc_content)), 1)
|
self.assertEqual(len(filter(contains_work, self.t.taskrc_content)), 1)
|
||||||
|
|
||||||
# Switch back to home context
|
# Switch back to home context
|
||||||
output = self.t(('context', 'home'))[1]
|
output = self.t(('context', 'home'))[1]
|
||||||
self.assertIn("Context 'home' applied.", output)
|
self.assertIn("Context 'home' set.", output)
|
||||||
|
|
||||||
self.assertNotIn("context=work\n", self.t.taskrc_content)
|
self.assertNotIn("context=work\n", self.t.taskrc_content)
|
||||||
self.assertEqual(len(filter(contains_home, self.t.taskrc_content)), 1)
|
self.assertEqual(len(filter(contains_home, self.t.taskrc_content)), 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue