poly ws
The poly
tool stores the workspace structure internally in an in-memory map.
It is used by poly
internally to support all commands.
All operations happen efficiently and directly on the map.
We expose the workspace structure via ws
to allow our users to explore the complete state of any workspace.
The workspace structure represents internal state and can change with new releases of poly .
See Versions for a changelog.
|
This document is a guide, see workspace structure for a complete reference.
All examples operate on our tutorial example workspace.
ws
We recommend you always use the shell. Its command autocompletion really shines when exploring workspace structures with the ws command. |
To return the entire workspace structure:
poly ws
The workspace structure is large.
You can limit what poly
returns via the get
argument.
For example, to return settings
:
poly ws get:settings
{:active-profiles #{"default"},
:color-mode "dark",
:compact-views #{},
:default-profile-name "default",
:empty-character ".",
:interface-ns "interface",
:m2-dir "/Users/joakimtengstrand/.m2",
:tag-patterns {:release "v[0-9]*", :stable "stable-*"},
:thousand-separator ",",
:top-namespace "se.example",
:user-config-filename "/Users/joakimtengstrand/.config/polylith/config.edn",
:user-home "/Users/joakimtengstrand",
:vcs {:auto-add true,
:branch "issue-315",
:git-root "/Users/joakimtengstrand/source/polylith",
:is-git-repo true,
:name "git",
:polylith {:branch "master",
:repo "https://github.com/polyfy/polylith.git"},
:stable-since {:sha "15453ebc5a86f52ee1c75ec52ebb19da4b113c30",
:tag "stable-master"}}}
See the workspace structure reference for descriptions.
If you are only interested in a specific element in this structure, you can dig deeper, e.g.:
poly ws get:profiles:default:paths
["components/user/src" "components/user/resources" "components/user/test"]
When exploring, it is nice to know what is available. To list top level keys:
poly ws get:keys
[:bases
:changes
:components
:configs
:interfaces
:messages
:name
:paths
:profiles
:projects
:settings
:user-input
:version
:ws-dir
:ws-local-dir
:ws-reader
:ws-type]
To list the components
keys:
poly ws get:components:keys
["user" "user-remote"]
To show the user
component:
poly ws get:components:user
{:interface {:definitions [{:name "hello"
:arglist [{:name "name"}]
:type "function"}]
:name "user"}
:interface-deps {:src [], :test []}
:lib-deps {}
:lib-imports {:test ["clojure.test"]}
:lines-of-code {:src 9, :test 7}
:name "user"
:namespaces {:src [{:file-path "components/user/src/se/example/user/interface.clj"
:imports ["se.example.user.core"]
:name "interface"
:namespace "se.example.user.interface"}
{:file-path "components/user/src/se/example/user/core.clj"
:imports []
:name "core"
:namespace "se.example.user.core"}]
:test [{:file-path "components/user/test/se/example/user/interface_test.clj"
:imports ["clojure.test" "se.example.user.interface"]
:name "interface-test"
:namespace "se.example.user.interface-test"}]}
:paths {:src ["src" "resources"], :test ["test"]}
:type "component"}
See the workspace structure reference for descriptions.
We’ve shown you how the libs command reports 3rd-party library usage.
You can also retrieve library usage via ws
, e.g.:
poly ws get:components:user-remote:lib-deps
{"compojure/compojure" {:size 15172, :type "maven", :version "1.6.2"},
"http-kit/http-kit" {:size 191467, :type "maven", :version "2.4.0"},
"ring/ring" {:size 4621, :type "maven", :version "1.8.1"},
"slacker/slacker" {:size 28408, :type "maven", :version "0.17.0"}}
To save output to a file:
poly ws out:ws.edn
An alternative way to reach the same result from your OS shell (e.g. bash, redirection does not work from the poly shell) is to turn off the coloring and redirect to ws.edn
:
poly ws color-mode:none > ws.edn
A saved workspace can be a convenient way to share the workspace structure with others without sharing the entire workspace codespace.
To load a workspace structure from a file, specify the ws-file
argument, e.g.:
poly info ws-file:ws.edn
You’ll see the same output as if you executed poly info
from the machine that created ws.edn
.
To inspect the arguments used to produce the file:
poly ws get:old:user-input:args ws-file:ws.edn
["ws" "out:ws.edn"]
Similar to ws-file is the ws-dir
argument.
It allows you to explore workspaces in other directories.
Like ws-file
, you can run all commands with ws-dir
except create and test.
Assuming you have a workspace in ../local-dep
, you could check it from your current directory like so:
poly check ws-dir:../local-dep
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close