Commit 39241a79 authored by Michael Rouse's avatar Michael Rouse

More work on the help screen

parent 70b052ab
......@@ -24,7 +24,7 @@ timeslime_args parse_args(int argc, char **argv)
if (num_args > 0)
{
result.action = args[0];
if (strcmp(HELP_ARG, args[0]) == 0)
if (strcmp(HELP_ACTION, args[0]) == 0)
{
result.help = True;
return result; // Nothing else matters
......@@ -66,7 +66,7 @@ timeslime_date parse_date(char *dateStr)
for (i = 0; i <= strlen(dateStr); i++)
{
// - and / are valid separators
if (dateStr[i] == '/' || dateStr[i] == '\0')
if (dateStr[i] == '/' || dateStr[i] == '-' || dateStr[i] == '\0')
{
log_debug("Found Date Separator: %c, read: %s", dateStr[i], running);
tmp = atoi(running);
......
......@@ -5,9 +5,7 @@
#include <stdlib.h>
#include <string.h>
#include "../logger.h"
/* Constants */
#define HELP_ARG "help"
#include "../string_literals.h"
#define False 0
......
......@@ -7,8 +7,17 @@
/* ACTIONS */
#define ADD_ACTION "add"
#define ADD_ACTION_DESCRIPTION "Add hours to your time sheet for a certain day. Defaults to the current date"
#define CLOCK_ACTION "clock"
#define CLOCK_ACTION_DESCRIPTION "Clock in or clock out of your time sheet"
#define REPORT_ACTION "report"
#define REPORT_ACTION_DESCRIPTION "Show all hours worked between two date ranges"
#define HELP_ACTION "help"
#define HELP_ACTION_DESCRIPTION "Receive information on how to use the program or an action"
/* Misc. */
#define TODAY "Today"
......@@ -17,4 +26,13 @@
#define CLOCK_OUT "out"
/* About */
#define PROGRAM_NAME "timeslime"
#define AUTHOR "Michael Rouse"
#define DESCRIPTION "\nTime Slime is a command line utility to keep \ntrack of hours worked remotely. \nA time sheet in your terminal!"
#define PROGRAM_VERSION "2018.08.14"
#endif
\ No newline at end of file
......@@ -18,7 +18,9 @@ int main(int argc, char *argv[])
parsed_args = parse_args(argc, argv);
if (parsed_args.help)
printf("Helping\n");
{
display_help();
}
else
{
if (strcmp(parsed_args.action, ADD_ACTION) == 0)
......@@ -126,4 +128,37 @@ void perform_report_action(timeslime_args args)
log_info("Running report between %s and %s", startDate.str, endDate.str);
}
/* Help Screen */
void display_help(void)
{
printf("Author: %s\n", AUTHOR);
printf("Version: %s\n", PROGRAM_VERSION);
printf("%s\n\n\n", DESCRIPTION);
printf("Usage:\n");
printf("\t%s [action] [arguments...]\n\n", PROGRAM_NAME);
printf("Actions:\n");
printf("\t%s\t %s\n", ADD_ACTION, ADD_ACTION_DESCRIPTION);
printf("\t%s\t %s\n", CLOCK_ACTION, CLOCK_ACTION_DESCRIPTION);
printf("\t%s\t %s\n", REPORT_ACTION, REPORT_ACTION_DESCRIPTION);
printf("\n");
printf("\t%s\t %s\n\n", HELP_ACTION, HELP_ACTION_DESCRIPTION);
printf("\n%s Action Usage:\n", ADD_ACTION);
printf("\t%s add (+|-)[0-9]\n", PROGRAM_NAME);
printf("\t%s add (+|-)[0-9] YYYY/MM/DD\n\n", PROGRAM_NAME);
printf("%s Action Usage:\n", CLOCK_ACTION);
printf("\t%s clock (in|out)\n\n", PROGRAM_NAME);
printf("%s Action Usage:\n", REPORT_ACTION);
printf("\t%s report YYYY/MM/DDD YYYY/MM/DDD\n", PROGRAM_NAME);
printf("\n");
}
\ No newline at end of file
......@@ -11,7 +11,7 @@
#include "args/args.h"
#include "logger.h"
#include "commands.h"
#include "string_literals.h"
/* Add to the time sheet */
......@@ -23,4 +23,7 @@ void perform_clock_action(timeslime_args args);
/* Show time worked for a period of time */
void perform_report_action(timeslime_args args);
/* Displays the help screen */
void display_help(void);
#endif
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment