Giter Club home page Giter Club logo

dosh-core's Introduction

HELLO ๐Ÿ‘‹

I'm GoeDev, living in Berlin, but sometimes I visit Ankara. I'm working as a Software Engineer at Mimi and coding in hearing technologies.

If you like my projects, you can support and motivate me. Sometimes I plan to open LiveCoding streams on Twitch. It depends on you.

LINKS

dosh-core's People

Contributors

gkmngrgn avatar goedev-mimi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

radity

dosh-core's Issues

`UnicodeDecodeError` in `run` command

$ dosh deploy
DOSH => [RUN] hugo
DOSH => [RUN] rsync -avz --delete public/ [email protected]:/var/www/html/gokmengorgen.net/
Traceback (most recent call last):
  File "app.py", line 12, in <module>
  File "app.py", line 8, in main
  File "dosh/cli.py", line 92, in run
  File "dosh/config.py", line 70, in run_task
  File "lupa/_lupa.pyx", line 587, in lupa._lupa._LuaObject.__call__
  File "lupa/_lupa.pyx", line 1333, in lupa._lupa.call_lua
  File "lupa/_lupa.pyx", line 1358, in lupa._lupa.execute_lua_call
  File "lupa/_lupa.pyx", line 281, in lupa._lupa.LuaRuntime.reraise_on_exception
  File "lupa/_lupa.pyx", line 1496, in lupa._lupa.py_call_with_gil
  File "lupa/_lupa.pyx", line 1483, in lupa._lupa.call_python
  File "dosh/commands/external.py", line 116, in run
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 11: invalid continuation byte
[64981] Failed to execute script 'app' due to unhandled exception!

Task Options

I want to know if a task accepts an option. In the help output, I should see all available options with the type, choices, and the default value.

dosh - shell-independent task manager

Tasks:
  > setup SETUP_TYPE     setup my operating system.
                         setup_type: all, emacs, python, shell, tmux (default: all)

Dosh commands:
  > help                 print this output
  > init                 initialize a new config in current working directory

  -c, --config PATH      specify config path (default: dosh.lua)
  -d, --directory PATH   change the working directory
  -v|vv|vvv, --verbose   increase the verbosity of messages:
                         1 - default, 2 - detailed, 3 - debug

An idea for config:

cmd.add_task {
    name = "setup",
    description = "setup my operating system.",
    required_platforms = {"macos"},
    command_options = {
        setup_type = {
            type = "string",
            options = {"all", "emacs", "python", "shell", "tmux"},
            default = "all"
        }
    },
    command = function(options)
        print(options)
    end
}

Add pre-description and post-description for help output.

My planned help output is like this one:

$ dosh help

dosh 0.1.0
shell-independent command manager

Tasks:
  > setup_my_os        place my config files.
  > install_cli_apps   install my favorite apps.
  > sync_repos         do not forget to push your changes before working on a different
                       laptop.
                       - repo_path: str, optional

If you are new to dosh, consider running `dosh --help` to learn using dosh.

This help output has three parts:

  • the first part includes the app name, version, description, etc.
  • tasks that show the available subcommand and its parameters.
  • the last line is about the --help parameter.

I want to allow the clients to edit the first and the last parts.

How could we rewrite this bash code in dosh?

for repo in $(curl -X GET "https://gitea.server/api/v1/repos/search?uid=goedev&limit=10000" \
                   -H "accept: application/json" \
                   -H "Authorization: token very-very-secret-token" \
                   -H "Content-Type: application/json" \
                   -s | jq -c ".data[] | {ssh_url,name}"); do
    ssh_url=$(echo $repo | jq -r ".ssh_url")
    name=$(echo $repo | jq -r ".name")
    repo_dir="$HOME/Workspace/goedev/$name"

    if [ -d $repo_dir ]; then
        echo "Repo $name is syncing..."
        git -C $repo_dir pull
    else
        echo "Repo $name is cloning..."
        git clone $ssh_url $repo_dir
    fi
    echo ""
done

Sync local folder with remote folder or vice-versa.

I've a command to sync my changes in my website with the server:

cmd.run("rsync -avz --delete public/ user@domain:/var/www/html/domain/")

But this command doesn't work if you don't have rsync. So, we need a native Python function to sync folders.

new command: `cmd.run_task`

There should be a function to run the other tasks.

Acceptance Criteria

  • check if there's a task with the specified name.
  • don't allow to run the task inside the same task.

Create the first release: v0.1.0

  • Add changelog file.
  • GitHub Actions should add the executable files to release page automatically.
  • Support Linux and MacOS first, then Windows.
  • Install pytest-coverage for reporting coverage.

Add verbosity option for dosh.

Instead of using print, we support four levels of logging:

  • debug
  • info
  • warning
  • error

Currently, dosh doesn't show any output. The default level should be info.

Handle `KeyboardInterrupt` when a task interrupted with `ctrl-c` / `ctrl-z`

$ DOSH_ENV="dev" dosh dev
DOSH => [RUN] hugo server -D --bind 0.0.0.0 -b mydomain
^CTraceback (most recent call last):
  File "app.py", line 12, in <module>
  File "app.py", line 8, in main
  File "dosh/cli.py", line 92, in run
  File "dosh/config.py", line 70, in run_task
  File "lupa/_lupa.pyx", line 587, in lupa._lupa._LuaObject.__call__
  File "lupa/_lupa.pyx", line 1333, in lupa._lupa.call_lua
  File "lupa/_lupa.pyx", line 1358, in lupa._lupa.execute_lua_call
  File "lupa/_lupa.pyx", line 281, in lupa._lupa.LuaRuntime.reraise_on_exception
  File "lupa/_lupa.pyx", line 1496, in lupa._lupa.py_call_with_gil
  File "lupa/_lupa.pyx", line 1483, in lupa._lupa.call_python
  File "dosh/commands/external.py", line 112, in run
KeyboardInterrupt
[64905] Failed to execute script 'app' due to unhandled exception!

new command: `run_dosh`

Sometimes I want to run a separate dosh config from another one. This can be in my file path or in a public url.

cmd.run_dosh(
    "https://raw.githubusercontent.com/gkmngrgn/emacs.d/main/dosh.lua",
    {task = "install", parameters = "--noconfirm"}
)

Additionally it may be a good idea to rename run_url command with run_bash or something else.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.