diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9aad4ee --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +all: git-help + +git-help: git-help.o + +.PHONY: clean +clean: + -rm -f git-help git-help.o diff --git a/README.md b/README.md index 3e1acaf..b00aef4 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,23 @@ -# Welcome the git tutorial Introduction! -This tutorial aims to teach you how to use `git` in an efficient manner for -your projects. This guide does not focus on `git` commands, but rather on -the things you need to do in order to write code in an easy to maintain -fashion. +# Welcome the git help tutorial! +The `git-help` tool found in this repository can be ran to find out more +information about git commands. -## Identity -When using `git` for the first time, the first step you need to do is to -identify yourself, so that whoever is interested in the portion of code you -wrote, they can easily reach you for further questions. In order to identify -yourself, you need to specify your name and email address to the `git` engine. -This is intuitively done using the `git config` command: +## Compile +You can compile the program using the `Makefile` in this project: ``` -git config --global user.name "YOUR NAME" -git config --global user.email "YOUR@EMAIL.ADDRESS" +make +``` +will generate the `git-help` executable. + +## Usage +When ran without parameters, the program returns the man page of the main git +command: +``` +./git-help +``` + +The program can also receive a parameter that indicates which command we want +to get more information about: +``` +./git-help commit ``` -Run these commands on your local computer; make sure you use a valid name and -email address! diff --git a/git-help.c b/git-help.c new file mode 100644 index 0000000..5cd7ab1 --- /dev/null +++ b/git-help.c @@ -0,0 +1,41 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +int main(int argc, char **argv) +{ + char *cmd; + if (argc > 2) { + fprintf(stderr, "Usage: %s [command]\n", argv[0]); + exit(-1); + } + + if (argc == 1) + system("man git"); + else { + cmd = malloc(9 + strlen(argv[argc])); + if (!cmd) { + fprintf(stderr, "not enought memory to create command!\n"); + exit(-1); + } + strcpy(cmd, "man git-"); + strcat(cmd, argv[argc]); + system(cmd); + } + + return 0; +}