Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve unphi #247

Open
deemp opened this issue Mar 1, 2024 · 2 comments
Open

Improve unphi #247

deemp opened this issue Mar 1, 2024 · 2 comments

Comments

@deemp
Copy link
Member

deemp commented Mar 1, 2024

I want to be able to run unphi

  • on a given file
  • or, all files from a given directory
  • without having to get .eoc from somewhere

I want to be able to run something like eoc unphi program.phi or eoc unphi dir.

For now, I have to run phi, get .eoc and then use it in unphi.

This script will unphi the files in try-unphi/phi and copy them to try-unphi/unphi.

set -euo pipefail

if ! [ -d node_modules ]; then npm i; fi

shopt -s expand_aliases
EO="0.35.5"
alias eo="npx eoc --parser=${EO}"

DIR=try-unphi

function prepare_directory {
    printf "\nClean the $DIR directory\n\n"

    mkdir -p $DIR/init
    mkdir -p $DIR/phi
    mkdir -p $DIR/tmp
    mkdir -p $DIR/unphi
}

function enter_directory {
    printf "\nEnter the $DIR directory\n\n"

    cd $DIR
}

function init_eoc {
    printf "\nGenerate an initial .eoc directory\n\n"

    cd init

    if [ ! -d .eoc ]; then
        cat <<EOM > test.eo
+alias org.eolang.io.stdout
+architect yegor256@gmail.com
+home https://github.com/objectionary/eo
+tests
+package org.eolang
+version 0.0.0

# Test.
[] > prints-itself
  gt. > @
    length.
      as-phi $
    0
EOM
        eo phi
    fi

    cd ..
}

function unphi {
    printf "\nUnphi\n\n"

    cd tmp
    rsync -r ../phi/ .
    rsync -r ../init/.eoc .
    eo unphi
    rsync -r .eoc/unphi/ --exclude org .eoc/2-optimize
    eo print
    rsync -r .eoc/print/ --exclude org ../unphi
    cd ..
}

prepare_directory
enter_directory
init_eoc
unphi
@deemp
Copy link
Member Author

deemp commented Mar 1, 2024

@yegor256, @maxonfjvipon, please advise a simpler way to run unphi if there's one.

@yegor256 yegor256 transferred this issue from objectionary/eo Mar 1, 2024
@yegor256
Copy link
Member

yegor256 commented Mar 7, 2024

@deemp you can use --target=/my/foo, which will make eoc use /my/foo instead of ~/.eoc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants