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

Feature Request - Chaining multiple commands in series #59

Closed
jygastaud opened this issue Feb 16, 2023 · 4 comments
Closed

Feature Request - Chaining multiple commands in series #59

jygastaud opened this issue Feb 16, 2023 · 4 comments
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@jygastaud
Copy link

Hi,

Thanks for the time you invest in that project. It will help a lot to explain concept.

What could be really cool would be to be able to chain many command and display an image with all those steps and not each step in individual image.

"Basic exemple" would be to have checkout a new branch, add, commit + merge in previous branch in the same image.

@paketb0te
Copy link
Contributor

Not a bad idea IMO, but I am not sure how we can build that - somehow we'd need to know whether a "word" is an argument to a previous command, or if it is already the next command to execute 🤔

To illustrate:

git_sim add foo.py commit stash pop

It might be kinda easy to figure out that foo.py is a file name (but what about files without extension?) and not a command, but how would we know if pop is a subcommand of stash, or a command on it's own?

I guess this might be doable by comparing each word to all command names and comparing it to "where in the command/subcommand tree are we right now?", but to me it looks not trivial to implement.

@paketb0te
Copy link
Contributor

paketb0te commented Feb 16, 2023

The simple case where each command takes no arguments is actually surprisingly simple, but of course it does not help with the previously mentioned problem...

import typer

app = typer.Typer()


@app.command(name="bar")
def bar():
    print("bar")


@app.command(name="baz")
def baz():
    print("baz")


@app.command(name="multi")
def multi(cmds: list[str]):
    registered_func_names = [reg_cmd.name for reg_cmd in app.registered_commands]
    for cmd in cmds:
        if cmd in registered_func_names:
            func = globals()[cmd]
            func()
        else:
            print(f"'{cmd}' is not a valid command, skipping...")


if __name__ == "__main__":
    app()
$ python foo.py multi one two bar foo baz baz boo bar
'one' is not a valid command, skipping...
'two' is not a valid command, skipping...
bar
'foo' is not a valid command, skipping...
baz
baz
'boo' is not a valid command, skipping...
bar

@jygastaud
Copy link
Author

jygastaud commented Feb 16, 2023

Not a bad idea IMO, but I am not sure how we can build that - somehow we'd need to know whether a "word" is an argument to a previous command, or if it is already the next command to execute thinking

I can imagine at least 3 different ways to handle that :

  1. Force seperator and/or quote each git command inside your line
    You exemple will become
    git_sim "add foo.py" "commit" "stash" "pop"
    
  2. Read a file that contain 1 command per line and just iterate over the file (sounds the easiest way for me)
  3. make git-sim "interactive" so you can run git-sim -i then enter a command, press enter, an other command, press enter…
    That is easy for small workflow but not that good from a UX perspective

@initialcommit-io initialcommit-io changed the title Feature Request - Chaining mulltiple command Feature Request - Chaining multiple commands in series Feb 16, 2023
@initialcommit-io initialcommit-io added enhancement New feature or request wontfix This will not be worked on labels Feb 16, 2023
@initialcommit-io
Copy link
Contributor

@jygastaud Interesting thought! We might consider this in the future but for now, we have to focus on getting full coverage of the most common Git commands before we think about chaining together into a larger workflow. Closing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants