From d84c9ad364d60a2339faf1a7464fe18364622b9c Mon Sep 17 00:00:00 2001 From: condret Date: Wed, 7 Jun 2023 21:15:43 +0200 Subject: [PATCH] Add halp --- fedi_post.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/fedi_post.c b/fedi_post.c index 6911e8f..d5e9927 100644 --- a/fedi_post.c +++ b/fedi_post.c @@ -37,6 +37,16 @@ static Sdb *load_sdb (char *path) { return ret; } +static void halp () { + puts ( "fedi_post [postfile] [-i] [-a " + " ...\n\n" + "postfile contains your post. alternativly you can use -i flag.\n" + "if you use -i flag fedi_post opens $EDITOR.\n" + "then you write your post, save, quit and fedi_post will do your post\n\n" + "you can also attach files to your posts with the -a flag.\n" + "if you use -a you need to provide the amount of files you want to attach to your post\n"); +} + static FediPostCFG *get_cfg (int argc, char *argv[]) { FediPostCFG *fpcfg; if (!argc || !(fpcfg = R_NEW0 (FediPostCFG))) { @@ -60,7 +70,6 @@ static FediPostCFG *get_cfg (int argc, char *argv[]) { eprintf ("'instance' is not set in %s :(\n", config_path); fail = true; } - puts (sdb_const_get (db, "instance", 0)); if (!sdb_exists (db, "user")) { eprintf ("'user' is not set in %s :(\n", config_path); fail = true; @@ -117,8 +126,19 @@ static FediPostCFG *get_cfg (int argc, char *argv[]) { !r_file_is_directory (argv[i])) { fpcfg->post = argv[i]; } + if (!strcmp (argv[i], "--help")) { + puts ("Who would type --help, if -h exists?"); + fail = true; + break; + } + if (!strcmp (argv[i], "-h")) { + halp (); + fail = true; + break; + } } if (fail) { + free (fpcfg->attachments); free (fpcfg->instance); free (fpcfg->creds); free (fpcfg);