Comments (5)
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.
from git-sim.
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
from git-sim.
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 :
- Force seperator and/or quote each git command inside your line
You exemple will becomegit_sim "add foo.py" "commit" "stash" "pop"
- Read a file that contain 1 command per line and just iterate over the file (sounds the easiest way for me)
- 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
from git-sim.
@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.
from git-sim.
Just started using git-sim few days ago and thought exactly the same.
So just wanted to say that the idea of chaining multiple commands sounds awesome to me and for me personally that would be extremely helpful.
I guess some kind of strategy to tackle the above mentioned issue regarding of separating commands, words, and arguments,
is simply requesting the user to create a file in which each command is in a separate line.
One other strategy, is using any special character to separate between commands (quotation marks would clearly be most intuitive but I aint sure that's gonna work)
from git-sim.
Related Issues (20)
- Error in Dockerfile during 'apt update' HOT 3
- git-sim not recognized as command in M1 Apple HOT 3
- Clarify license HOT 5
- TypeError: can only concatenate str (not "ManimColor") to str HOT 4
- Thank you! HOT 1
- Request: Make CHENGELOG.md HOT 1
- Font size is wrong HOT 5
- Cannot run git-sim to generate only images HOT 6
- Error on simple actions HOT 7
- Auto-completion is extremely slow HOT 6
- git submodule not support HOT 2
- Add -v, --version flag to display program version info HOT 2
- Implement PEP 621 (pyproject.toml) and migrate to "src" layout HOT 14
- Support gif animations HOT 1
- Extremely slow on larger repos HOT 9
- Arrow direction HOT 2
- AttributeError: module 'manim' has no attribute 'ArrowTriangleFilledTip' HOT 7
- Two branches without common commit? git-annex use case HOT 14
- --animate log in chronological order of the commits HOT 9
- Refine test suite HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from git-sim.