diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d767d6..101550c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,29 +1,20 @@ name: CI -# Controls when the workflow will run on: - # Triggers the workflow on push or pull request events but only for the "main" branch push: branches: [ "main" ] pull_request: branches: [ "main" ] - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" build: - # The type of runner that the job will run on runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - # Runs a single command using the runners shell - name: Starting tests run: | echo Starting tests diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e082b4b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM bash:latest + +RUN mkdir /home/root/ + +RUN apk add --no-cache coreutils + +WORKDIR /woche + +COPY . /woche diff --git a/README.md b/README.md index 6265fce..38622cb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Woche -Woche is a collection of Bash scripts that assist in managing weekly tasks. It enables the creation of a new Markdown file for the current week and the addition of tasks to specific days. Woche, meaning 'week' in German, uses German day names (Montag, Dienstag, Mittwoch, Donnerstag, Freitag, Samstag, and Sonntag) for educational purposes. You can choose between options with the names of the days in English or German. +Woche is a collection of Bash scripts that assist in managing weekly tasks. It enables the creation of a new Markdown file for the current week and the addition of tasks to specific days. Woche, meaning 'week' in German. You can choose between options with the names of the days in English or German. ## Features @@ -10,22 +10,23 @@ Woche is a collection of Bash scripts that assist in managing weekly tasks. It e ## Usage -1. **Create a new Markdown file for the current week (starting on Monday):** +**Create a new Markdown file for the current week (starting on Monday):** ```bash ./woche.sh create ``` + This command creates a file using the YYMMDD format. -2. **Add a task to a specific day:** +**Add a task to a specific day:** ```bash ./woche.sh "" ``` -Replace with the day of the week (in German: mon, die, mit, don, frei, sam, son) and with the task description. +Replace with the day of the week and with the task description. The days in German are: mon, die, mit, don, frei, sam and son, in English: mond, tue, wed, thu, fri, sat and sun. -3. **Display the tasks of the current week:** +**Display the tasks of the current week:** ```bash ./woche.sh show @@ -33,7 +34,7 @@ Replace with the day of the week (in German: mon, die, mit, don, frei, sam This command prints the Markdown file with the tasks for the entire week. -4. **Edit a task of the current week:** +**Edit a task of the current week:** ```bash ./woche.sh edit 9 "That task" @@ -41,7 +42,7 @@ This command prints the Markdown file with the tasks for the entire week. This command edit the line 9 of Markdown file with the tasks. -5. **Delete a task of the current week:** +**Delete a task of the current week:** ```bash ./woche.sh delete 3 @@ -49,17 +50,12 @@ This command edit the line 9 of Markdown file with the tasks. This command edit the line 3 of Markdown file. -6. **Access instructions:** +**Access instructions:** ```bash ./woche.sh help ``` -## Customization Tips -- Change the file creation path by modifying the path variable in the variables.sh file. -- Switch to English day names by replacing woche_array with week_array in the same file. -- Alter the date format of the Markdown file by adjusting the start_day_of_week method in functions.sh. - ## Testing The test.sh script tests the functionality of woche.sh, checking both correct and incorrect user inputs. This test is mandatory for pull requests to the main branch and should be included in the [GitHub Actions](https://github.com/0jonjo/woche/actions) pipeline for automated testing. @@ -69,6 +65,28 @@ To run the tests: ```bash ./test.sh ``` + +## Docker + +To use the dockerized version of Woche, follow these instructions: + +```bash +# Build the image +docker build -t woche-app . + +# Run the container +docker run -it woche-app +``` + +## Customization Tips + +- Change the file creation path by modifying the path variable in the variables.sh file. +- Switch to German day names by replacing week_array with woche_array in the same file. +- Alter the date format of the Markdown file by adjusting the start_day_of_week method in functions.sh. +- Use dockerized version if not in Ubuntu/Debian like system operation. + --- + ## License + This project is licensed under the GNU License. See the [LICENSE](LICENSE) file for details. diff --git a/functions.sh b/functions.sh index 51fd92a..b1ceabc 100755 --- a/functions.sh +++ b/functions.sh @@ -1,11 +1,9 @@ -#!/bin/bash - -#Path: functions.sh +#!/usr/bin/env bash tips() { echo "tips: woche.sh" echo "create: a new markdown file for the current week" - echo "${woche_array_string[@]}: to add a task to the day of the week." + echo "${week_array_string[@]}: to add a task to the day of the week." } start_day_of_week() { @@ -18,27 +16,27 @@ start_day_of_week() { file_exists() { if [ ! -e "$start_day.md" ]; then - echo "The file $start_day.md does not exist." + echo "Error: The file $start_day.md does not exist." exit 1 fi } file_already_exists() { if [ -e "$start_day.md" ]; then - echo "The file $start_day.md already exists." + echo "Error: The file $start_day.md already exists." exit 1 fi } line_exists() { if [ -z "$(sed -n "${task}p" "$start_day.md")" ]; then - echo "Line $task does not exist." + echo "Error: Line $task does not exist." exit 1 fi } create_file() { - for i in "${woche_array[@]}"; do + for i in "${week_array[@]}"; do printf "# %s\n\n" "$i" >> "$start_day.md" done echo "The file $start_day.md has been created." diff --git a/tests.sh b/tests.sh index 3351fe6..b553342 100644 --- a/tests.sh +++ b/tests.sh @@ -1,8 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash -# Path to the woche.sh script -source $(dirname "$0")/functions.sh -source $(dirname "$0")/variables.sh +source functions.sh +source variables.sh woche_script_path="./woche.sh" @@ -23,7 +22,7 @@ delete_file() { delete_file # Test with more than 3 arguments -output=$("$woche_script_path" mon "Test task" "Argument" "Extra argument") +output=$("$woche_script_path" mont "Test task" "Argument" "Extra argument") if [[ "$output" == *"tips: woche.sh"* ]]; then echo "Test 'more than 3 arguments' command: PASSED" else @@ -67,7 +66,7 @@ else fi # Test add task to a day command -output=$("$woche_script_path" mon "Test task") +output=$("$woche_script_path" mond "Test task") if [[ "$output" == *"Task 'Test task' added to"* ]]; then echo "Test 'add task to a day' command: PASSED" else diff --git a/variables.sh b/variables.sh index 7457b2e..eda28ff 100755 --- a/variables.sh +++ b/variables.sh @@ -1,6 +1,4 @@ -#!/bin/bash - -#Path: variables.sh +#!/usr/bin/env bash # The path to create and edit the file path="/home/$(whoami)/" @@ -26,7 +24,8 @@ woche_array=($mon $die $mit $don $fre $sam $son) week_array=($mond $tue $wed $thu $fri $sat $sun) woche_array_string=("mon" "die" "mit" "don" "fre" "sam" "son") +week_array_string=("mond" "tue" "wed" "thu" "fri" "sat" "sun") options=("create" "show" "help" "delete" "edit") # Create an array that is options + woche_array name of variables as strings -options_to_check=("${options[@]}" "${woche_array_string[@]}") +options_to_check=("${options[@]}" "${week_array_string[@]}") diff --git a/woche.sh b/woche.sh index e6fddc2..1426c9f 100755 --- a/woche.sh +++ b/woche.sh @@ -1,8 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash -# Path: woche.sh -source $(dirname "$0")/functions.sh -source $(dirname "$0")/variables.sh +source functions.sh +source variables.sh cd "$path" @@ -19,7 +18,7 @@ fi # Check if $1 is in the options to check if [[ ! " ${options_to_check[@]} " =~ " $1 " ]]; then - echo "Invalid command." + echo "Error: Invalid command." tips exit 1 fi