polyfy / polylith

A tool used to develop Polylith based architectures in Clojure.
Eclipse Public License 1.0
499 stars 47 forks source link

Switch workspace via shortcuts #443

Closed tengstrand closed 2 weeks ago

tengstrand commented 4 months ago

Add support for switching workspace via shortcuts that are specified in the :ws-shortcuts key in the user config file ~/.config/polylith/config.edn (the value of :root-dir is added to the paths), e.g.:

{...
 :ws-shortcuts {:root-dir "/Users/joakimtengstrand/source/polylith"
                :paths [{:dir "examples/doc-example"}
                        {:dir "examples/multiple-workspaces2/backend"}
                        {:dir "../clojure-polylith-realworld-example-app" :name "realworld"}
                        {:file "../sandbox/another-ws.edn"}]
}

Now we can switch workspace with via:NAME where NAME is the name of the directory/file, or :name if given, e.g.:

polylith$ switch-ws via:
backend       (examples/multiple-workspaces2/backend)
doc-example                    (examples/doc-example)
realworld (../clojure-polylith-realworld-example-app)
another-ws (../sandbox/another-ws.edn)

If we for example select realworld then the tool will perform a switch-ws dir:../clojure-polylith-realworld-example-app for us:

polylith$ switch-ws via:realworld
dir:clojure-polylith-realworld-example-app$

We can always switch back to the root workspace with:

dir:clojure-polylith-realworld-example-app$ switch-ws
polylith$

It's also possible to switch to a workspace that has been exported to a file:

polylith$ switch-ws via:another-ws
file:another-ws$