diff options
-rw-r--r-- | .github/workflows/main.yml | 39 | ||||
-rw-r--r-- | Cargo.lock | 154 | ||||
-rw-r--r-- | Cargo.toml | 7 | ||||
-rw-r--r-- | src/app/impl_self.rs | 8 | ||||
-rw-r--r-- | src/command.rs | 3 | ||||
-rw-r--r-- | src/main.rs | 23 |
6 files changed, 210 insertions, 24 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8ccbae..5c3e6f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml | |||
@@ -39,7 +39,7 @@ jobs: | |||
39 | && sudo apt-get install -y \ | 39 | && sudo apt-get install -y \ |
40 | libdbus-1-dev | 40 | libdbus-1-dev |
41 | - name: Build | 41 | - name: Build |
42 | run: cargo build --all --release && strip target/release/dijo | 42 | run: cargo build -all --no-default-features --features unix --release && strip target/release/dijo |
43 | 43 | ||
44 | - name: Upload binaries to release | 44 | - name: Upload binaries to release |
45 | uses: svenstaro/upload-release-action@v1-release | 45 | uses: svenstaro/upload-release-action@v1-release |
@@ -72,7 +72,7 @@ jobs: | |||
72 | override: true | 72 | override: true |
73 | 73 | ||
74 | - name: Build for mac | 74 | - name: Build for mac |
75 | run: cargo build --all --release && strip target/release/dijo | 75 | run: cargo build --all --no-default-features --features unix --release && strip target/release/dijo |
76 | 76 | ||
77 | - name: Upload binaries to release | 77 | - name: Upload binaries to release |
78 | uses: svenstaro/upload-release-action@v1-release | 78 | uses: svenstaro/upload-release-action@v1-release |
@@ -82,3 +82,38 @@ jobs: | |||
82 | asset_name: dijo-x86_64-apple | 82 | asset_name: dijo-x86_64-apple |
83 | tag: ${{ github.ref }} | 83 | tag: ${{ github.ref }} |
84 | overwrite: true | 84 | overwrite: true |
85 | |||
86 | build-windows: | ||
87 | runs-on: windows-latest | ||
88 | |||
89 | steps: | ||
90 | - name: Checkout | ||
91 | uses: actions/checkout@v1 | ||
92 | - name: Cache Rust dependencies | ||
93 | uses: actions/[email protected] | ||
94 | with: | ||
95 | path: target | ||
96 | key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} | ||
97 | restore-keys: | | ||
98 | ${{ runner.OS }}-build- | ||
99 | - name: Install latest rust toolchain | ||
100 | uses: actions-rs/toolchain@v1 | ||
101 | with: | ||
102 | toolchain: beta | ||
103 | target: x86_64-pc-windows-msvc | ||
104 | default: true | ||
105 | override: true | ||
106 | |||
107 | - name: Build for windows | ||
108 | run: | | ||
109 | cargo build --all --no-default-features --features windows --release | ||
110 | strip target/release/dijo | ||
111 | |||
112 | - name: Upload binaries to release | ||
113 | uses: svenstaro/upload-release-action@v1-release | ||
114 | with: | ||
115 | repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
116 | file: target/release/dijo | ||
117 | asset_name: dijo-x86_64-windows | ||
118 | tag: ${{ github.ref }} | ||
119 | overwrite: true | ||
@@ -125,6 +125,15 @@ dependencies = [ | |||
125 | ] | 125 | ] |
126 | 126 | ||
127 | [[package]] | 127 | [[package]] |
128 | name = "cloudabi" | ||
129 | version = "0.0.3" | ||
130 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
131 | checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" | ||
132 | dependencies = [ | ||
133 | "bitflags", | ||
134 | ] | ||
135 | |||
136 | [[package]] | ||
128 | name = "const-random" | 137 | name = "const-random" |
129 | version = "0.1.8" | 138 | version = "0.1.8" |
130 | source = "registry+https://github.com/rust-lang/crates.io-index" | 139 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -152,12 +161,12 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" | |||
152 | 161 | ||
153 | [[package]] | 162 | [[package]] |
154 | name = "crossbeam-channel" | 163 | name = "crossbeam-channel" |
155 | version = "0.4.2" | 164 | version = "0.4.3" |
156 | source = "registry+https://github.com/rust-lang/crates.io-index" | 165 | source = "registry+https://github.com/rust-lang/crates.io-index" |
157 | checksum = "cced8691919c02aac3cb0a1bc2e9b73d89e832bf9a06fc579d4e71b68a2da061" | 166 | checksum = "09ee0cc8804d5393478d743b035099520087a5186f3b93fa58cec08fa62407b6" |
158 | dependencies = [ | 167 | dependencies = [ |
168 | "cfg-if", | ||
159 | "crossbeam-utils", | 169 | "crossbeam-utils", |
160 | "maybe-uninit", | ||
161 | ] | 170 | ] |
162 | 171 | ||
163 | [[package]] | 172 | [[package]] |
@@ -172,6 +181,31 @@ dependencies = [ | |||
172 | ] | 181 | ] |
173 | 182 | ||
174 | [[package]] | 183 | [[package]] |
184 | name = "crossterm" | ||
185 | version = "0.17.7" | ||
186 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
187 | checksum = "6f4919d60f26ae233e14233cc39746c8c8bb8cd7b05840ace83604917b51b6c7" | ||
188 | dependencies = [ | ||
189 | "bitflags", | ||
190 | "crossterm_winapi", | ||
191 | "lazy_static", | ||
192 | "libc", | ||
193 | "mio 0.7.0", | ||
194 | "parking_lot", | ||
195 | "signal-hook", | ||
196 | "winapi 0.3.9", | ||
197 | ] | ||
198 | |||
199 | [[package]] | ||
200 | name = "crossterm_winapi" | ||
201 | version = "0.6.1" | ||
202 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
203 | checksum = "057b7146d02fb50175fd7dbe5158f6097f33d02831f43b4ee8ae4ddf67b68f5c" | ||
204 | dependencies = [ | ||
205 | "winapi 0.3.9", | ||
206 | ] | ||
207 | |||
208 | [[package]] | ||
175 | name = "ctor" | 209 | name = "ctor" |
176 | version = "0.1.15" | 210 | version = "0.1.15" |
177 | source = "registry+https://github.com/rust-lang/crates.io-index" | 211 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -190,6 +224,7 @@ dependencies = [ | |||
190 | "ahash 0.3.8", | 224 | "ahash 0.3.8", |
191 | "cfg-if", | 225 | "cfg-if", |
192 | "crossbeam-channel", | 226 | "crossbeam-channel", |
227 | "crossterm", | ||
193 | "cursive_core", | 228 | "cursive_core", |
194 | "enumset", | 229 | "enumset", |
195 | "lazy_static", | 230 | "lazy_static", |
@@ -260,7 +295,7 @@ dependencies = [ | |||
260 | 295 | ||
261 | [[package]] | 296 | [[package]] |
262 | name = "dijo" | 297 | name = "dijo" |
263 | version = "0.1.5" | 298 | version = "0.2.1" |
264 | dependencies = [ | 299 | dependencies = [ |
265 | "chrono", | 300 | "chrono", |
266 | "clap", | 301 | "clap", |
@@ -522,6 +557,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
522 | checksum = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9" | 557 | checksum = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9" |
523 | 558 | ||
524 | [[package]] | 559 | [[package]] |
560 | name = "lock_api" | ||
561 | version = "0.3.4" | ||
562 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
563 | checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" | ||
564 | dependencies = [ | ||
565 | "scopeguard", | ||
566 | ] | ||
567 | |||
568 | [[package]] | ||
525 | name = "log" | 569 | name = "log" |
526 | version = "0.4.11" | 570 | version = "0.4.11" |
527 | source = "registry+https://github.com/rust-lang/crates.io-index" | 571 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -531,12 +575,6 @@ dependencies = [ | |||
531 | ] | 575 | ] |
532 | 576 | ||
533 | [[package]] | 577 | [[package]] |
534 | name = "maybe-uninit" | ||
535 | version = "2.0.0" | ||
536 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
537 | checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" | ||
538 | |||
539 | [[package]] | ||
540 | name = "mio" | 578 | name = "mio" |
541 | version = "0.6.22" | 579 | version = "0.6.22" |
542 | source = "registry+https://github.com/rust-lang/crates.io-index" | 580 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -549,13 +587,27 @@ dependencies = [ | |||
549 | "kernel32-sys", | 587 | "kernel32-sys", |
550 | "libc", | 588 | "libc", |
551 | "log", | 589 | "log", |
552 | "miow", | 590 | "miow 0.2.1", |
553 | "net2", | 591 | "net2", |
554 | "slab", | 592 | "slab", |
555 | "winapi 0.2.8", | 593 | "winapi 0.2.8", |
556 | ] | 594 | ] |
557 | 595 | ||
558 | [[package]] | 596 | [[package]] |
597 | name = "mio" | ||
598 | version = "0.7.0" | ||
599 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
600 | checksum = "6e9971bc8349a361217a8f2a41f5d011274686bd4436465ba51730921039d7fb" | ||
601 | dependencies = [ | ||
602 | "lazy_static", | ||
603 | "libc", | ||
604 | "log", | ||
605 | "miow 0.3.5", | ||
606 | "ntapi", | ||
607 | "winapi 0.3.9", | ||
608 | ] | ||
609 | |||
610 | [[package]] | ||
559 | name = "mio-extras" | 611 | name = "mio-extras" |
560 | version = "2.0.6" | 612 | version = "2.0.6" |
561 | source = "registry+https://github.com/rust-lang/crates.io-index" | 613 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -563,7 +615,7 @@ checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" | |||
563 | dependencies = [ | 615 | dependencies = [ |
564 | "lazycell", | 616 | "lazycell", |
565 | "log", | 617 | "log", |
566 | "mio", | 618 | "mio 0.6.22", |
567 | "slab", | 619 | "slab", |
568 | ] | 620 | ] |
569 | 621 | ||
@@ -580,6 +632,16 @@ dependencies = [ | |||
580 | ] | 632 | ] |
581 | 633 | ||
582 | [[package]] | 634 | [[package]] |
635 | name = "miow" | ||
636 | version = "0.3.5" | ||
637 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
638 | checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" | ||
639 | dependencies = [ | ||
640 | "socket2", | ||
641 | "winapi 0.3.9", | ||
642 | ] | ||
643 | |||
644 | [[package]] | ||
583 | name = "net2" | 645 | name = "net2" |
584 | version = "0.2.34" | 646 | version = "0.2.34" |
585 | source = "registry+https://github.com/rust-lang/crates.io-index" | 647 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -602,13 +664,22 @@ dependencies = [ | |||
602 | "fsevent-sys", | 664 | "fsevent-sys", |
603 | "inotify", | 665 | "inotify", |
604 | "libc", | 666 | "libc", |
605 | "mio", | 667 | "mio 0.6.22", |
606 | "mio-extras", | 668 | "mio-extras", |
607 | "walkdir", | 669 | "walkdir", |
608 | "winapi 0.3.9", | 670 | "winapi 0.3.9", |
609 | ] | 671 | ] |
610 | 672 | ||
611 | [[package]] | 673 | [[package]] |
674 | name = "ntapi" | ||
675 | version = "0.3.4" | ||
676 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
677 | checksum = "7a31937dea023539c72ddae0e3571deadc1414b300483fa7aaec176168cfa9d2" | ||
678 | dependencies = [ | ||
679 | "winapi 0.3.9", | ||
680 | ] | ||
681 | |||
682 | [[package]] | ||
612 | name = "num" | 683 | name = "num" |
613 | version = "0.3.0" | 684 | version = "0.3.0" |
614 | source = "registry+https://github.com/rust-lang/crates.io-index" | 685 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -687,6 +758,30 @@ dependencies = [ | |||
687 | ] | 758 | ] |
688 | 759 | ||
689 | [[package]] | 760 | [[package]] |
761 | name = "parking_lot" | ||
762 | version = "0.10.2" | ||
763 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
764 | checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" | ||
765 | dependencies = [ | ||
766 | "lock_api", | ||
767 | "parking_lot_core", | ||
768 | ] | ||
769 | |||
770 | [[package]] | ||
771 | name = "parking_lot_core" | ||
772 | version = "0.7.2" | ||
773 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
774 | checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" | ||
775 | dependencies = [ | ||
776 | "cfg-if", | ||
777 | "cloudabi", | ||
778 | "libc", | ||
779 | "redox_syscall", | ||
780 | "smallvec", | ||
781 | "winapi 0.3.9", | ||
782 | ] | ||
783 | |||
784 | [[package]] | ||
690 | name = "proc-macro-hack" | 785 | name = "proc-macro-hack" |
691 | version = "0.5.16" | 786 | version = "0.5.16" |
692 | source = "registry+https://github.com/rust-lang/crates.io-index" | 787 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -694,9 +789,9 @@ checksum = "7e0456befd48169b9f13ef0f0ad46d492cf9d2dbb918bcf38e01eed4ce3ec5e4" | |||
694 | 789 | ||
695 | [[package]] | 790 | [[package]] |
696 | name = "proc-macro2" | 791 | name = "proc-macro2" |
697 | version = "1.0.18" | 792 | version = "1.0.19" |
698 | source = "registry+https://github.com/rust-lang/crates.io-index" | 793 | source = "registry+https://github.com/rust-lang/crates.io-index" |
699 | checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" | 794 | checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" |
700 | dependencies = [ | 795 | dependencies = [ |
701 | "unicode-xid", | 796 | "unicode-xid", |
702 | ] | 797 | ] |
@@ -764,6 +859,12 @@ dependencies = [ | |||
764 | ] | 859 | ] |
765 | 860 | ||
766 | [[package]] | 861 | [[package]] |
862 | name = "scopeguard" | ||
863 | version = "1.1.0" | ||
864 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
865 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" | ||
866 | |||
867 | [[package]] | ||
767 | name = "serde" | 868 | name = "serde" |
768 | version = "1.0.114" | 869 | version = "1.0.114" |
769 | source = "registry+https://github.com/rust-lang/crates.io-index" | 870 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -801,6 +902,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
801 | checksum = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed" | 902 | checksum = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed" |
802 | dependencies = [ | 903 | dependencies = [ |
803 | "libc", | 904 | "libc", |
905 | "mio 0.7.0", | ||
804 | "signal-hook-registry", | 906 | "signal-hook-registry", |
805 | ] | 907 | ] |
806 | 908 | ||
@@ -821,6 +923,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
821 | checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" | 923 | checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" |
822 | 924 | ||
823 | [[package]] | 925 | [[package]] |
926 | name = "smallvec" | ||
927 | version = "1.4.1" | ||
928 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
929 | checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" | ||
930 | |||
931 | [[package]] | ||
932 | name = "socket2" | ||
933 | version = "0.3.12" | ||
934 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
935 | checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" | ||
936 | dependencies = [ | ||
937 | "cfg-if", | ||
938 | "libc", | ||
939 | "redox_syscall", | ||
940 | "winapi 0.3.9", | ||
941 | ] | ||
942 | |||
943 | [[package]] | ||
824 | name = "stable_deref_trait" | 944 | name = "stable_deref_trait" |
825 | version = "1.2.0" | 945 | version = "1.2.0" |
826 | source = "registry+https://github.com/rust-lang/crates.io-index" | 946 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -840,9 +960,9 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" | |||
840 | 960 | ||
841 | [[package]] | 961 | [[package]] |
842 | name = "syn" | 962 | name = "syn" |
843 | version = "1.0.34" | 963 | version = "1.0.35" |
844 | source = "registry+https://github.com/rust-lang/crates.io-index" | 964 | source = "registry+https://github.com/rust-lang/crates.io-index" |
845 | checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b" | 965 | checksum = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0" |
846 | dependencies = [ | 966 | dependencies = [ |
847 | "proc-macro2", | 967 | "proc-macro2", |
848 | "quote", | 968 | "quote", |
@@ -1,6 +1,6 @@ | |||
1 | [package] | 1 | [package] |
2 | name = "dijo" | 2 | name = "dijo" |
3 | version = "0.1.5" | 3 | version = "0.2.1" |
4 | authors = ["Akshay <[email protected]>"] | 4 | authors = ["Akshay <[email protected]>"] |
5 | edition = "2018" | 5 | edition = "2018" |
6 | description = "Scriptable, curses-based, digital habit tracker" | 6 | description = "Scriptable, curses-based, digital habit tracker" |
@@ -23,7 +23,10 @@ notify = "4.0" | |||
23 | [dependencies.cursive] | 23 | [dependencies.cursive] |
24 | version = "0.15" | 24 | version = "0.15" |
25 | default-features = false | 25 | default-features = false |
26 | features = ["termion-backend"] | 26 | |
27 | [features] | ||
28 | unix = ["cursive/termion-backend"] | ||
29 | windows = ["cursive/crossterm-backend"] | ||
27 | 30 | ||
28 | [dependencies.chrono] | 31 | [dependencies.chrono] |
29 | version = "0.4" | 32 | version = "0.4" |
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index cf0e97f..a806dc5 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs | |||
@@ -128,7 +128,7 @@ impl App { | |||
128 | let completed = total - remaining; | 128 | let completed = total - remaining; |
129 | 129 | ||
130 | let timestamp = if self.view_month_offset == 0 { | 130 | let timestamp = if self.view_month_offset == 0 { |
131 | format!("{}", Local::now().date().format("%d/%b/%y"),) | 131 | format!("{}", Local::now().naive_local().date().format("%d/%b/%y"),) |
132 | } else { | 132 | } else { |
133 | let months = self.view_month_offset; | 133 | let months = self.view_month_offset; |
134 | format!("{}", format!("{} months ago", months),) | 134 | format!("{}", format!("{} months ago", months),) |
@@ -217,6 +217,12 @@ impl App { | |||
217 | match result { | 217 | match result { |
218 | Ok(c) => match c { | 218 | Ok(c) => match c { |
219 | Command::Add(name, goal, auto) => { | 219 | Command::Add(name, goal, auto) => { |
220 | if let Some(_) = self.habits.iter().find(|x| x.name() == name) { | ||
221 | self.message.set_kind(MessageKind::Error); | ||
222 | self.message | ||
223 | .set_message(format!("Habit `{}` already exist", &name)); | ||
224 | return; | ||
225 | } | ||
220 | let kind = if goal == Some(1) { "bit" } else { "count" }; | 226 | let kind = if goal == Some(1) { "bit" } else { "count" }; |
221 | if kind == "count" { | 227 | if kind == "count" { |
222 | self.add_habit(Box::new(Count::new(name, goal.unwrap_or(0), auto))); | 228 | self.add_habit(Box::new(Count::new(name, goal.unwrap_or(0), auto))); |
diff --git a/src/command.rs b/src/command.rs index a893430..ae5be66 100644 --- a/src/command.rs +++ b/src/command.rs | |||
@@ -61,8 +61,7 @@ pub fn open_command_window(s: &mut Cursive) { | |||
61 | let completion = get_habit_completion(word, &habit_list); | 61 | let completion = get_habit_completion(word, &habit_list); |
62 | eprintln!("{:?} | {:?}", completion, contents); | 62 | eprintln!("{:?} | {:?}", completion, contents); |
63 | if let Some(c) = completion { | 63 | if let Some(c) = completion { |
64 | let cb = | 64 | let cb = view.set_content(format!("{}", contents) + &c[word.len()..]); |
65 | view.set_content(format!("{}", contents) + c.strip_prefix(word).unwrap()); | ||
66 | return Some(EventResult::Consumed(Some(cb))); | 65 | return Some(EventResult::Consumed(Some(cb))); |
67 | }; | 66 | }; |
68 | return None; | 67 | return None; |
diff --git a/src/main.rs b/src/main.rs index d96119e..609738e 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -12,7 +12,13 @@ use crate::command::{open_command_window, Command}; | |||
12 | use crate::utils::{load_configuration_file, AppConfig}; | 12 | use crate::utils::{load_configuration_file, AppConfig}; |
13 | 13 | ||
14 | use clap::{App as ClapApp, Arg}; | 14 | use clap::{App as ClapApp, Arg}; |
15 | |||
16 | #[cfg(any(target_os = "linux", target_os = "macos"))] | ||
15 | use cursive::termion; | 17 | use cursive::termion; |
18 | |||
19 | #[cfg(target_os = "windows")] | ||
20 | use cursive::crossterm; | ||
21 | |||
16 | use cursive::views::{LinearLayout, NamedView}; | 22 | use cursive::views::{LinearLayout, NamedView}; |
17 | use lazy_static::lazy_static; | 23 | use lazy_static::lazy_static; |
18 | 24 | ||
@@ -33,6 +39,14 @@ fn main() { | |||
33 | .value_name("CMD") | 39 | .value_name("CMD") |
34 | .help("run a dijo command"), | 40 | .help("run a dijo command"), |
35 | ) | 41 | ) |
42 | .arg( | ||
43 | Arg::with_name("list") | ||
44 | .short("l") | ||
45 | .long("list") | ||
46 | .takes_value(false) | ||
47 | .help("list dijo habits") | ||
48 | .conflicts_with("command"), | ||
49 | ) | ||
36 | .get_matches(); | 50 | .get_matches(); |
37 | if let Some(c) = matches.value_of("command") { | 51 | if let Some(c) = matches.value_of("command") { |
38 | let command = Command::from_string(c); | 52 | let command = Command::from_string(c); |
@@ -49,8 +63,17 @@ fn main() { | |||
49 | "Commands other than `track-up` and `track-down` are currently not supported!" | 63 | "Commands other than `track-up` and `track-down` are currently not supported!" |
50 | ), | 64 | ), |
51 | } | 65 | } |
66 | } else if matches.is_present("list") { | ||
67 | for h in App::load_state().list_habits() { | ||
68 | println!("{}", h); | ||
69 | } | ||
52 | } else { | 70 | } else { |
71 | #[cfg(target_os = "windows")] | ||
72 | let mut s = crossterm().unwrap(); | ||
73 | |||
74 | #[cfg(any(target_os = "linux", target_os = "macos"))] | ||
53 | let mut s = termion().unwrap(); | 75 | let mut s = termion().unwrap(); |
76 | |||
54 | let app = App::load_state(); | 77 | let app = App::load_state(); |
55 | let layout = NamedView::new( | 78 | let layout = NamedView::new( |
56 | "Frame", | 79 | "Frame", |