pipe-game

Un jeu de cartes à piper les une dans les autres - retour accueil

git clone git://bebou.netlib.re/pipe-game
Log | Files | Refs | README |

commit f70461146ce5452abecd417fcec104009df2f7eb
Auterice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Fri, 28 Jun 2024 17:02:35 +0200

Premier commit

Des sources, des filtres, des commandes pour gérer tout ça

choose-source permet de choisir une source
create-pipeline est un petit wrapper autour de fzy pour construire son
pipeline. Il devrait être amélioré pour pouvoir bouger des cartes déjà
placées sans repartir de 0
test-pipeline exécute la pipeline pour voir sa sortie
show-pipeline affiche la série de pipe qui sera exécutée, avec -a
affiche les commandes à l'intérieurs des cartes jouées

Diffstat:
AREADME | 4++++
Acards/filters/append | 2++
Acards/filters/combine-columns | 1+
Acards/filters/double | 1+
Acards/filters/double-nth-line | 1+
Acards/filters/double-second-line | 1+
Acards/filters/keep | 1+
Acards/filters/keep-first-column | 1+
Acards/filters/keep-numbers | 1+
Acards/filters/minus-n-numbers | 3+++
Acards/filters/minus-one-numbers | 3+++
Acards/filters/plus-one-numbers | 3+++
Acards/filters/print-arg-three-times | 3+++
Acards/filters/print-card-n-times | 3+++
Acards/filters/print-n-times | 3+++
Acards/filters/remove | 1+
Acards/filters/remove-first | 1+
Acards/filters/remove-last | 1+
Acards/filters/reverse | 1+
Acards/filters/save | 1+
Acards/filters/swap-attack-defend | 2++
Acards/source/all-in | 2++
Acards/source/defend | 2++
Acards/source/strike | 2++
Achoose-source | 1+
Acreate-pipeline | 11+++++++++++
Ashow-pipeline | 6++++++
Atest-pipeline | 1+
28 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -0,0 +1,4 @@ +Un jeu de carte expérimental UNIX + +où y'a des cartes sources et des cartes filtres et faut les piper +et ça fait des trucs diff --git a/cards/filters/append b/cards/filters/append @@ -0,0 +1,2 @@ +cat +sed -n '2,$ p' $1 diff --git a/cards/filters/combine-columns b/cards/filters/combine-columns @@ -0,0 +1 @@ +paste - $1 diff --git a/cards/filters/double b/cards/filters/double @@ -0,0 +1 @@ +sed 'p' diff --git a/cards/filters/double-nth-line b/cards/filters/double-nth-line @@ -0,0 +1 @@ +sed "$1 p" diff --git a/cards/filters/double-second-line b/cards/filters/double-second-line @@ -0,0 +1 @@ +sed '2 p' diff --git a/cards/filters/keep b/cards/filters/keep @@ -0,0 +1 @@ +grep -E "$1" diff --git a/cards/filters/keep-first-column b/cards/filters/keep-first-column @@ -0,0 +1 @@ +cut -d ' ' -f1 diff --git a/cards/filters/keep-numbers b/cards/filters/keep-numbers @@ -0,0 +1 @@ +grep -Eo -- "-?[0-9]+" diff --git a/cards/filters/minus-n-numbers b/cards/filters/minus-n-numbers @@ -0,0 +1,3 @@ + sed -E "s/(-?[0-9]+)/$(( \1 - $1 ))/g + s/^/echo /" | + sh diff --git a/cards/filters/minus-one-numbers b/cards/filters/minus-one-numbers @@ -0,0 +1,3 @@ + sed -E 's/(-?[0-9]+)/$(( \1 - 1 ))/g + s/^/echo /' | + sh diff --git a/cards/filters/plus-one-numbers b/cards/filters/plus-one-numbers @@ -0,0 +1,3 @@ +sed -E 's/(-?[0-9]+)/$(( \1 + 1 ))/g + s/^/echo /' | + sh diff --git a/cards/filters/print-arg-three-times b/cards/filters/print-arg-three-times @@ -0,0 +1,3 @@ +for i in $(seq 3);do + echo $@ +done diff --git a/cards/filters/print-card-n-times b/cards/filters/print-card-n-times @@ -0,0 +1,3 @@ +for i in $(seq $2);do + cat $1 +done diff --git a/cards/filters/print-n-times b/cards/filters/print-n-times @@ -0,0 +1,3 @@ +for i in $(seq $2);do + cat $1 +done diff --git a/cards/filters/remove b/cards/filters/remove @@ -0,0 +1 @@ +grep -vE "$1" diff --git a/cards/filters/remove-first b/cards/filters/remove-first @@ -0,0 +1 @@ +sed '1 d' diff --git a/cards/filters/remove-last b/cards/filters/remove-last @@ -0,0 +1 @@ +sed '$ d' diff --git a/cards/filters/reverse b/cards/filters/reverse @@ -0,0 +1 @@ +tac diff --git a/cards/filters/save b/cards/filters/save @@ -0,0 +1 @@ +tee "$1" diff --git a/cards/filters/swap-attack-defend b/cards/filters/swap-attack-defend @@ -0,0 +1,2 @@ +sed -z 's/attack/d/g;s/defend/a/g' | + sed -z 's/d/defend/g;s/a/attack/g' diff --git a/cards/source/all-in b/cards/source/all-in @@ -0,0 +1,2 @@ +attack 20 +health -10 diff --git a/cards/source/defend b/cards/source/defend @@ -0,0 +1,2 @@ +# Ajoute 5 de block +defend 5 diff --git a/cards/source/strike b/cards/source/strike @@ -0,0 +1,2 @@ +# Fait 6 de dégâts +attack 6 diff --git a/choose-source b/choose-source @@ -0,0 +1 @@ +find cards -type f | fzy | xargs -r -I{} cp {} source diff --git a/create-pipeline b/create-pipeline @@ -0,0 +1,11 @@ +rm -rf pipeline/* +nb="1" +while :;do + card=$(find cards/filters -type f | fzy) + [ -z "$card" ] && exit 0 + grep -q "\$1" $card && read -p "argument : " arg + echo "$card" | + xargs basename | + xargs -r -I {} cp cards/filters/{} pipeline/$nb-{}+$arg + nb=$(( $nb + 1 )) +done diff --git a/show-pipeline b/show-pipeline @@ -0,0 +1,6 @@ +[ $1 = "-a" ] \ +&& { find pipeline -type f | + sort | + xargs -n1 sh -c 'cat $1 | sed "$ s/$/ |/"' --; } \ +|| { printf "cat source/* | $(find pipeline -type f | sort | sed -E 's/\+(.*)/+\1 \1/' | paste -s -d '|') \n" | sed 's/|/|\n /g'; } + diff --git a/test-pipeline b/test-pipeline @@ -0,0 +1 @@ +printf "cat source/* | $(find pipeline -type f | sort | sed -E 's/\+(.*)/+\1 \1/' | paste -s -d '|')" | sh