Compare commits
4 Commits
13cb4d1d9a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 323ddea27e | |||
| 1bea4d30ef | |||
|
|
213ee60807 | ||
|
|
1c89507497 |
@@ -5,8 +5,8 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"gitea.bel.blue/gogs/pttodo/pttodo"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"gitea.inhome.blapointe.com/gogs/pttodo/pttodo"
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"gitea.inhome.blapointe.com/gogs/pttodo/pttodo"
|
"gitea.bel.blue/gogs/pttodo/pttodo"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gitea.inhome.blapointe.com/gogs/pttodo/pttodo"
|
"gitea.bel.blue/gogs/pttodo/pttodo"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
@@ -204,7 +204,7 @@ func vimd(d string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
args := []string{editorbin, "-p"}
|
args := []string{editorbin, "--noplugin", "-p"}
|
||||||
files, err := listDir(d)
|
files, err := listDir(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
13
cmd/go.mod
13
cmd/go.mod
@@ -1,13 +0,0 @@
|
|||||||
module pttodo-cli
|
|
||||||
|
|
||||||
go 1.21
|
|
||||||
|
|
||||||
require (
|
|
||||||
gitea.inhome.blapointe.com/gogs/pttodo v0.0.0-20231109151914-5d74b458d542
|
|
||||||
github.com/google/uuid v1.3.0
|
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
|
||||||
)
|
|
||||||
|
|
||||||
require github.com/robfig/cron/v3 v3.0.1 // indirect
|
|
||||||
|
|
||||||
replace gogs.inhome.blapointe.com/gogs/pttodo => ./..
|
|
||||||
10
cmd/go.sum
10
cmd/go.sum
@@ -1,10 +0,0 @@
|
|||||||
gitea.inhome.blapointe.com/gogs/pttodo v0.0.0-20231109151914-5d74b458d542 h1:eOWrA2hEQoyu413vbdXbEXHLXEX2TVBXjWawlWndFhg=
|
|
||||||
gitea.inhome.blapointe.com/gogs/pttodo v0.0.0-20231109151914-5d74b458d542/go.mod h1:9CFZf/SSod0Z/8WvbmOI4gEzy6xGpBQAq8coVNncNvk=
|
|
||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
||||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
|
||||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
cd "$(dirname "$BASH_SOURCE")"
|
cd "$(dirname "$BASH_SOURCE")"
|
||||||
|
|
||||||
binary_name="$(head -n 1 go.mod | awk '{print $NF}' | sed 's/.*\///')"
|
binary_name="$(head -n 1 go.mod | awk '{print $NF}' | sed 's/.*\///')"
|
||||||
|
binary_name=pttodo-cli
|
||||||
git_commit="$((
|
git_commit="$((
|
||||||
git rev-list -1 HEAD
|
git rev-list -1 HEAD
|
||||||
if git diff | grep . > /dev/null; then
|
if git diff | grep . > /dev/null; then
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"gitea.inhome.blapointe.com/gogs/pttodo/pttodo"
|
"gitea.bel.blue/gogs/pttodo/pttodo"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|||||||
3
go.mod
3
go.mod
@@ -1,8 +1,9 @@
|
|||||||
module gitea.inhome.blapointe.com/gogs/pttodo
|
module gitea.bel.blue/gogs/pttodo
|
||||||
|
|
||||||
go 1.21
|
go 1.21
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/google/uuid v1.6.0
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
)
|
)
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -1,3 +1,5 @@
|
|||||||
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
|
|||||||
17
pttodoest/src/deltas.rs
Normal file
17
pttodoest/src/deltas.rs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
pub fn new(added: String, add_schedule: Option<String>) -> serde_yaml::Value {
|
||||||
|
match add_schedule.clone() {
|
||||||
|
None => new_add(added),
|
||||||
|
Some(add_schedule) => new_add_with_schedule(added, add_schedule),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_add(added: String) -> serde_yaml::Value {
|
||||||
|
serde_yaml::Value::String(added)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_add_with_schedule(added: String, schedule: String) -> serde_yaml::Value {
|
||||||
|
let mut m = serde_yaml::Mapping::new();
|
||||||
|
m.insert("schedule".into(), schedule.into());
|
||||||
|
m.insert("do".into(), added.into());
|
||||||
|
serde_yaml::Value::Mapping(m)
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use crate::tests as tests_pkg;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_yaml;
|
use serde_yaml;
|
||||||
@@ -70,7 +72,7 @@ mod test_flags {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_flags_files_unhidden_only() {
|
fn test_flags_files_unhidden_only() {
|
||||||
tests::with_dir(|d| {
|
tests_pkg::with_dir(|d| {
|
||||||
std::fs::File::create(d.path().join("plain")).unwrap();
|
std::fs::File::create(d.path().join("plain")).unwrap();
|
||||||
std::fs::File::create(d.path().join(".hidden")).unwrap();
|
std::fs::File::create(d.path().join(".hidden")).unwrap();
|
||||||
|
|
||||||
@@ -86,11 +88,3 @@ mod test_flags {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
pub fn with_dir(mut foo: impl FnMut(tempdir::TempDir)) {
|
|
||||||
foo(tempdir::TempDir::new("").unwrap());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
use crate::deltas as deltas_pkg;
|
||||||
use crate::flags as flags_pkg;
|
use crate::flags as flags_pkg;
|
||||||
|
mod deltas;
|
||||||
mod flags;
|
mod flags;
|
||||||
|
mod tests;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let flags = flags_pkg::Flags::new().expect("failed to flags");
|
let flags = flags_pkg::Flags::new().expect("failed to flags");
|
||||||
@@ -26,7 +29,7 @@ pub fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn add(files: Vec<String>, added: String, add_schedule: Option<String>) -> Result<(), String> {
|
fn add(files: Vec<String>, added: String, add_schedule: Option<String>) -> Result<(), String> {
|
||||||
let task = Delta::new(added, add_schedule);
|
let task = deltas::new(added, add_schedule);
|
||||||
|
|
||||||
Err(format!("append {:?} to {:?}", &task, &files))
|
Err(format!("append {:?} to {:?}", &task, &files))
|
||||||
}
|
}
|
||||||
@@ -43,26 +46,6 @@ fn dump(files: Vec<String>) -> Result<(), String> {
|
|||||||
Err("not impl".to_string())
|
Err("not impl".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
mod Delta {
|
|
||||||
pub fn new(added: String, add_schedule: Option<String>) -> serde_yaml::Value {
|
|
||||||
match add_schedule.clone() {
|
|
||||||
None => new_add(added),
|
|
||||||
Some(add_schedule) => new_add_with_schedule(added, add_schedule),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new_add(added: String) -> serde_yaml::Value {
|
|
||||||
serde_yaml::Value::String(added)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new_add_with_schedule(added: String, schedule: String) -> serde_yaml::Value {
|
|
||||||
let mut m = serde_yaml::Mapping::new();
|
|
||||||
m.insert("schedule".into(), schedule.into());
|
|
||||||
m.insert("do".into(), added.into());
|
|
||||||
serde_yaml::Value::Mapping(m)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
mod v1 {
|
mod v1 {
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|||||||
3
pttodoest/src/tests.rs
Normal file
3
pttodoest/src/tests.rs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
pub fn with_dir(mut foo: impl FnMut(tempdir::TempDir)) {
|
||||||
|
foo(tempdir::TempDir::new("").unwrap());
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user