commit 45b2881f7bb29ce49e86e2baf007981b04db84c3
parent 14d248e1f8f0d97be78f22de40ab8e9325fc604b
Author: Claudio Alessi <smoppy@gmail.com>
Date: Tue, 26 Jan 2016 20:10:53 +0100
If no arguments, goes for one day.
Diffstat:
3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
@@ -3,13 +3,13 @@ snore - sleep with feedback
SYNOPSIS
- snore [-v] NUMBER[SUFFIX]...
+ snore [-v] [NUMBER[SUFFIX]...]
snore pause for NUMBER seconds. SUFFIX may be 's' for seconds (default), 'm'
for minutes, 'h' four hours or 'd' for days. Given two or more arguments, pause
for the amount of time specified by the sum of their values. A visual feedback
is given by printing the flowing of time in both ascending and descending
-order.
+order. If no arguments are given, snore goes for 1d.
SHORTCUTS
diff --git a/snore.1 b/snore.1
@@ -4,14 +4,14 @@ snore \- sleep with feedback
.SH SYNOPSIS
.B snore
.RB [ \-v ]
-.RI "" NUMBER [ SUFFIX ]...
+.RI [ NUMBER [ SUFFIX ]... ]
.SH DESCRIPTION
.B snore
-pause for NUMBER seconds. SUFFIX may be 's' for seconds (default), 'm'
-for minutes, 'h' four hours or 'd' for days. Given two or more arguments, pause
-for the amount of time specified by the sum of their values. A visual feedback
-is given by printing the flowing of time in both ascending and descending
-order.
+pause for NUMBER seconds. SUFFIX may be 's' for seconds (default), 'm' for
+minutes, 'h' four hours or 'd' for days. Given two or more arguments, pause for
+the amount of time specified by the sum of their values. A visual feedback is
+given by printing the flowing of time in both ascending and descending order.
+If no arguments are given, snore goes for 1d.
.SH SHORTCUTS
.TP
.B Enter
diff --git a/snore.c b/snore.c
@@ -88,11 +88,9 @@ main(int argc, char *argv[]) {
double tm, endtm;
int i;
- if(argc < 2)
- die("Usage: %s [-v] [time ...]\n", *argv);
- if(!strcmp("-v", argv[1]))
+ if(argc == 2 && !strcmp("-v", argv[1]))
die("snore-"VERSION", © 2016 Claudio Alessi, see LICENSE for details\n");
-
+
endtm = 0;
for(i = 1; i < argc; ++i) {
tm = time_to_sec(argv[i]);
@@ -101,10 +99,15 @@ main(int argc, char *argv[]) {
endtm += time_to_sec(argv[i]);
}
+ if(argc == 1 && !endtm)
+ endtm = symbols[LENGTH(symbols) - 1].mult;
+
for(tm = 0; tm < endtm; tm += DELTA) {
time_print(tm); /* ascending */
- printf(" | ");
- time_print(endtm - tm); /* descending */
+ if(endtm) {
+ printf(" | ");
+ time_print(endtm - tm); /* descending */
+ }
fflush(stdout);
usleep(TICK);
printf("%s", SCLEAR);