Compare commits
4 commits
561fd9e1e5
...
5dbea00562
Author | SHA1 | Date | |
---|---|---|---|
|
5dbea00562 | ||
|
cc1e9d4d69 | ||
|
d5e6bd2578 | ||
|
60b33b1dd3 |
4 changed files with 56 additions and 24 deletions
14
README.md
14
README.md
|
@ -2,6 +2,12 @@
|
|||
|
||||
An immutable nested collaborative task manager, powered by nostr!
|
||||
|
||||
> Mostr is beta software.
|
||||
> Do not entrust it exclusively with your data unless you know what you are doing!
|
||||
|
||||
> Intermediate versions might not properly persist all changes.
|
||||
> A failed relay connection currently looses all intermediate changes.
|
||||
|
||||
## Quickstart
|
||||
|
||||
First, start a nostr relay, such as
|
||||
|
@ -24,6 +30,11 @@ Install latest build:
|
|||
|
||||
cargo install --path .
|
||||
|
||||
This one-liner can help you stay on the latest version
|
||||
(optionally add a `cd` to your mostr-directory in front):
|
||||
|
||||
git pull && cargo install --path . && mostr
|
||||
|
||||
Creating a test task externally:
|
||||
`nostril --envelope --content "test task" --kind 1621 | websocat ws://localhost:4736`
|
||||
|
||||
|
@ -163,6 +174,7 @@ Append `@TIME` to any task creation or change command to record the action with
|
|||
- with string argument, find first matching task in history
|
||||
- with int argument, jump back X tasks in history
|
||||
- undo last action (moving in place or upwards confirms pending actions)
|
||||
- `*` - (un)bookmark current task or list all bookmarks
|
||||
- `wss://...` - switch or subscribe to relay (prefix with space to forcibly add a new one)
|
||||
|
||||
Property Filters:
|
||||
|
@ -171,7 +183,7 @@ Property Filters:
|
|||
- `+TAG` - add tag filter (empty: list all used tags)
|
||||
- `-TAG` - remove tag filters (by prefix)
|
||||
- `?STATUS` - set status filter (type or description) - plain `?` to reset, `??` to show all
|
||||
- `*INT` - set priority filter
|
||||
- `*INT` - set priority filter - `**` to reset
|
||||
- `@[AUTHOR|TIME]` - filter by time or author (pubkey, or `@` for self, TBI: id prefix, name prefix)
|
||||
|
||||
Status descriptions can be used for example for Kanban columns or review flows.
|
||||
|
|
|
@ -5,7 +5,6 @@ use log::info;
|
|||
use nostr_sdk::TagStandard::Hashtag;
|
||||
use nostr_sdk::{Alphabet, EventBuilder, EventId, Kind, Tag, TagKind, TagStandard};
|
||||
use std::borrow::Cow;
|
||||
use std::iter::once;
|
||||
|
||||
pub const TASK_KIND: Kind = Kind::GitIssue;
|
||||
pub const PROCEDURE_KIND_ID: u16 = 1639;
|
||||
|
@ -150,8 +149,10 @@ pub(crate) fn to_prio_tag(value: Prio) -> Tag {
|
|||
|
||||
#[test]
|
||||
fn test_extract_tags() {
|
||||
assert_eq!(extract_tags("Hello from #mars with #greetings *4 # yeah done-it"),
|
||||
assert_eq!(extract_tags("Hello from #mars with #greetings *4 # # yeah done-it"),
|
||||
("Hello from #mars with #greetings".to_string(),
|
||||
["mars", "greetings", "yeah", "done-it"].into_iter().map(to_hashtag)
|
||||
.chain(once(Tag::custom(TagKind::Custom(Cow::from(PRIO)), [40.to_string()]))).collect()))
|
||||
.chain(std::iter::once(Tag::custom(TagKind::Custom(Cow::from(PRIO)), [40.to_string()]))).collect()));
|
||||
assert_eq!(extract_tags("So tagless #"),
|
||||
("So tagless".to_string(), vec![]));
|
||||
}
|
38
src/main.rs
38
src/main.rs
|
@ -4,8 +4,7 @@ use std::env::{args, var};
|
|||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::{BufRead, BufReader, Write};
|
||||
use std::iter::once;
|
||||
use std::ops::{Add, Sub};
|
||||
use std::ops::Sub;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
@ -28,7 +27,7 @@ use tokio::time::timeout;
|
|||
|
||||
use crate::helpers::*;
|
||||
use crate::kinds::{Prio, BASIC_KINDS, PROPERTY_COLUMNS, PROP_KINDS, TRACKING_KIND};
|
||||
use crate::task::{State, Task, TaskState, MARKER_DEPENDS};
|
||||
use crate::task::{State, Task, TaskState};
|
||||
use crate::tasks::{PropertyCollection, StateFilter, TasksRelay};
|
||||
|
||||
mod helpers;
|
||||
|
@ -448,20 +447,18 @@ async fn main() -> Result<()> {
|
|||
Some(',') =>
|
||||
match arg {
|
||||
None => {
|
||||
match tasks.get_current_task() {
|
||||
None => {
|
||||
info!("With a task selected, use ,NOTE to attach NOTE and , to list all its notes");
|
||||
tasks.recurse_activities = !tasks.recurse_activities;
|
||||
info!("Toggled activities recursion to {}", tasks.recurse_activities);
|
||||
}
|
||||
Some(task) => {
|
||||
if let Some(task) = tasks.get_current_task() {
|
||||
let mut desc = task.description_events().peekable();
|
||||
if desc.peek().is_some() {
|
||||
println!("{}",
|
||||
task.description_events()
|
||||
.map(|e| format!("{} {}", format_timestamp_local(&e.created_at), e.content))
|
||||
desc.map(|e| format!("{} {}", format_timestamp_local(&e.created_at), e.content))
|
||||
.join("\n"));
|
||||
continue 'repl;
|
||||
}
|
||||
}
|
||||
info!("With a task selected, use ,NOTE to attach NOTE and , to list all its notes");
|
||||
tasks.recurse_activities = !tasks.recurse_activities;
|
||||
info!("Toggled activities recursion to {}", tasks.recurse_activities);
|
||||
}
|
||||
Some(arg) => {
|
||||
if arg.len() < CHARACTER_THRESHOLD {
|
||||
|
@ -537,7 +534,8 @@ async fn main() -> Result<()> {
|
|||
match arg {
|
||||
None => match tasks.get_position() {
|
||||
None => {
|
||||
tasks.set_priority(None);
|
||||
info!("Showing only bookmarked tasks");
|
||||
tasks.set_view_bookmarks();
|
||||
}
|
||||
Some(pos) =>
|
||||
match or_warn!(tasks.toggle_bookmark(pos)) {
|
||||
|
@ -548,8 +546,7 @@ async fn main() -> Result<()> {
|
|||
},
|
||||
Some(arg) => {
|
||||
if arg == "*" {
|
||||
info!("Showing only bookmarked tasks");
|
||||
tasks.set_view_bookmarks();
|
||||
tasks.set_priority(None);
|
||||
} else {
|
||||
tasks.set_priority(arg.parse()
|
||||
.inspect_err(|e| warn!("Invalid Priority {arg}: {e}")).ok()
|
||||
|
@ -623,18 +620,21 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
Some('#') =>
|
||||
tasks.set_tags(arg_default.split_whitespace().map(|s| Hashtag(s.to_string()).into())),
|
||||
Some('#') => {
|
||||
if !tasks.update_tags(arg_default.split_whitespace().map(|s| Hashtag(s.to_string()).into())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Some('+') =>
|
||||
match arg {
|
||||
Some(arg) => tasks.add_tag(arg.to_string()),
|
||||
None => {
|
||||
println!("Hashtags of all known tasks:\n{}", tasks.all_hashtags().join(" ").italic());
|
||||
tasks.print_hashtags();
|
||||
if tasks.has_tag_filter() {
|
||||
println!("Use # to remove tag filters and . to remove all filters.")
|
||||
}
|
||||
continue 'repl;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
21
src/tasks.rs
21
src/tasks.rs
|
@ -647,7 +647,26 @@ impl TasksRelay {
|
|||
!self.tags.is_empty() || !self.tags_excluded.is_empty()
|
||||
}
|
||||
|
||||
pub(crate) fn set_tags(&mut self, tags: impl IntoIterator<Item=Tag>) {
|
||||
pub(crate) fn print_hashtags(&self) {
|
||||
println!("Hashtags of all known tasks:\n{}", self.all_hashtags().join(" ").italic());
|
||||
}
|
||||
|
||||
/// Returns true if tags have been updated, false if it printed something
|
||||
pub(crate) fn update_tags(&mut self, tags: impl IntoIterator<Item=Tag>) -> bool {
|
||||
let mut peekable = tags.into_iter().peekable();
|
||||
if self.tags.is_empty() && peekable.peek().is_none() {
|
||||
if !self.tags_excluded.is_empty() {
|
||||
self.tags_excluded.clear();
|
||||
}
|
||||
self.print_hashtags();
|
||||
false
|
||||
} else {
|
||||
self.set_tags(peekable);
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
fn set_tags(&mut self, tags: impl IntoIterator<Item=Tag>) {
|
||||
self.tags.clear();
|
||||
self.tags.extend(tags);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue