summary refs log tree commit diff stats
path: root/tests/stdlib/tstrimpl.nim
Commit message (Collapse)AuthorAgeFilesLines
* stdlib tests now check refc too (#21664)ringabout2023-04-211-0/+4
| | | | | | | | | | | * stdlib tests now check refc too * typo * fixes line numbers * disable cpp * do not touch
* fixed tstrimpl (#20452)Andreas Rumpf2022-09-291-0/+2
|
* fix #19500; remove find optimization [backport: 1.6] (#19714)ringabout2022-09-281-0/+6
* remove find optimization close #19500 * save find to std * add simple tests * Apply suggestions from code review Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: sandytypical <43030857+xflywind@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
a id='n105' href='#n105'>105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then
    set -o xtrace
fi

EDITOR="subl"

add-moons () {
    if [[ -d ".moons" ]]; then
        touch ".moons/$1"
        echo -e "A new moon is orbiting $2"
    else
        path=$(pwd)
        while [ -n "$path" ]; do
            path=${path%/*}
            if [ -d "$path/.moons" ]; then
                touch "$path/.moons/$1"
                echo -e "A new moon is orbiting $2"
                return
            fi
        done
    fi
}

open-moons () {
    if [[ -d ".moons" ]]; then
        for file in .moons/$1; do
            echo -e "$file"
            $EDITOR "$file"
        done
    else
        path=$(pwd)
        while [ -n "$path" ]; do
            path=${path%/*}
            if [ -d "$path/.moons" ]; then
                for file in $path/.moons/$1; do
                    echo -e "$file"
                    $EDITOR "$file"
                done
                return
            fi
        done
    fi
}

PRE_SHORT_RAND=$(openssl rand -base64 6)
SHORT_RAND=${PRE_SHORT_RAND//\//_}

help_text() {
    echo '
    Moon Maker

    mm, is a small program that lets you add orbiting moons to planet files.

    A planet file is one that you care about -- probably an actual file in your project.
    Moon files orbit planets, they are disposable scratch spaces connected to planets.

    usage: ./mm
                    -i(nit)....initialize a directory to store moon files
                    -o(pen)....open a planet file and all of its moon files
                    -a(dd).....create a new moon file for a given planet file
                    -d(elete)..remove a moon file by its id
                    -c(lear)...remove all moon files for a given planet file
                    -u(pdate)..rename a planet file and all of its moon files
'
}

if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
    help_text "$@"
    exit
elif [[ "${1-}" =~ ^-*i(nit)?$ ]]; then
    if [[ ! -d ".moons" ]]; then
        mkdir ".moons"
        echo -e "moons initialized"
    else
        echo -e "   
            a moon maker directory already exists 
            so you can't add another one here.
            "
    fi
    exit
elif [[ "${1-}" =~ ^-*o(pen)?$ ]]; then
    $EDITOR "$2"
    open-moons "$2*"
    exit
elif [[ "${1-}" =~ ^-*a(dd)?$ ]]; then
    if [  $# -ge 3 ]; then
        FILE_TYPE="$3" # optionally pass a file type you'd like to append to the moon
    else
        FILE_TYPE="txt" # if you don't provide a file type, assume .txt for the new moon
    fi
    NEW_MOON="$2"."$SHORT_RAND"."$FILE_TYPE"
    add-moons "$NEW_MOON" "$2"
    exit
elif [[ "${1-}" =~ ^-*d(elete)?$ ]]; then
    echo "delete"
    exit
elif [[ "${1-}" =~ ^-*c(lear)?$ ]]; then
    echo "clear"
    exit
elif [[ "${1-}" =~ ^-*u(pdate)?$ ]]; then
    echo "update"
    exit
elif [[ "${1-}" =~ ^-*z(eplin)?$ ]]; then
    echo -e "zeplin"
    $EDITOR "$2"
    exit
fi

cd "$(dirname "$0")"

main() {
    help_text "$@"
}

main "$@"