{"id":23284201,"url":"https://github.com/agilecreativity/swiza-sh","last_synced_at":"2025-09-21T16:40:06.872Z","repository":{"id":62433766,"uuid":"205561678","full_name":"agilecreativity/swiza-sh","owner":"agilecreativity","description":"Simple wrapper to clj-ssh","archived":false,"fork":false,"pushed_at":"2023-03-18T04:25:29.000Z","size":13,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-18T16:52:10.203Z","etag":null,"topics":["clojure","clojure-library","ssh-client"],"latest_commit_sha":null,"homepage":"https://github.com/agilecreativity/swiza-sh","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agilecreativity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-08-31T15:25:03.000Z","updated_at":"2024-01-03T23:32:44.000Z","dependencies_parsed_at":"2025-06-18T06:42:26.661Z","dependency_job_id":null,"html_url":"https://github.com/agilecreativity/swiza-sh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/agilecreativity/swiza-sh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fswiza-sh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fswiza-sh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fswiza-sh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fswiza-sh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agilecreativity","download_url":"https://codeload.github.com/agilecreativity/swiza-sh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fswiza-sh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276272761,"owners_count":25614209,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-21T02:00:07.055Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","clojure-library","ssh-client"],"created_at":"2024-12-20T01:38:38.118Z","updated_at":"2025-09-21T16:40:06.793Z","avatar_url":"https://github.com/agilecreativity.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"## swiza-sh\n\n[![Clojars Project](https://img.shields.io/clojars/v/net.b12n/swiza-sh.svg)](https://clojars.org/net.b12n/swiza-sh)\n[![Dependencies Status](https://jarkeeper.com/agilecreativity/swiza-sh/status.png)](https://jarkeeper.com/agilecreativity/swiza-sh)\n![ClojarsDownloads](https://img.shields.io/clojars/dt/net.b12n/swiza-sh)\n\nClojure library designed to wrap the execution of shell script to make it easy to manipulate the result.\n\nThe library rely on the awesome power of [clj-common-exec][1] which wrap the functionality of [apache-common-exec][2]\n\n[1]: https://github.com/hozumi/clj-commons-exec\n[2]: http://commons.apache.org/proper/commons-exec\n\n### Installation\n\nJust include the following line in your dependency vector\n\n```clojure\n[net.b12n/swiza-sh \"0.1.3\"]\n```\n\n### Available Apis\n\n- sh-cmd - run a single shell command\n- sh-cmds - run multiple shell commands\n- run-cmds - run multiple shell commands (alternative api)\n- sh-exec - run command with callback function\n\n### Example Usages\n\n```clojure\n(require '[b12n.swiza.commons :refer [expand-path]])\n(require '[b12n.swiza.sh.core :refer [sh-cmd sh-cmds run-cmds sh-exec]])\n```\n\n- `run-cmds` : run multiple commands optionally stop on first error\n\n```clojure\n;; a)\n(run-cmds {:dir \\\".\\\"\n           :cmds [\\\"ls -alt\\\"\n                  \\\"find . -type f -iname \\\"*.clj\\\"]})\n;; b) Similar to the first usage, but stop on the first error\n(run-cmds {:dir \\\".\\\"\n           :ignore-error? false\n           :cmds [\\\"ls -alt\\\"\n                  \\\"invalid-command\\\"\n                  \\\"find . -type f -iname \\\"*.clj\\\"]})\n\n;; c) Run multiple command using that run in start from different directory (ignore error)\n;; e.g. don't specify `:dir` option\n(run-cmds {:cmds [\\\"ls -alt\\\"\n                  \\\"find . -type f -iname \\\"*.clj\\\"]})\n\n;; d) Same as above but stop on first error\n(run-cmds {:ignore-error? false\n             :cmds [\\\"ls -alt\\\"\n                    \\\"find . -type f -iname \\\"*.clj\\\"]})\"\n```\n\n- `sh-cmds` : run multiple command using the original api\n\nBuild multiple Clojure projects using Leiningen\n\n```clojure\n(sh-cmds [{:cmd [\"lein\" \"deps\" \":tree\"] :opts {:dir (expand-path \"~/apps/swiza/swiza-commons\")}}\n          {:cmd [\"lein\" \"deps\" \":tree\"] :opts {:dir (expand-path \"~/apps/swiza/swiza-jenkins\")}}\n          {:cmd [\"lein\" \"deps\" \":tree\"] :opts {:dir (expand-path \"~/apps/swiza/swiza-aws\")}}])\n```\n\nBuild and run GraalVM native image from Clojure\n\n```clojure\n;; Build and run the GraalVM project using `lein native-image`\n(let [base-dir (expand-path \"~/apps/swizz/swiza-graal\")]\n  (sh-cmds [{:cmd [\"lein\" \"deps\" \":tree\"] :opts {:dir base-dir}}\n            {:cmd [\"lein\" \"native-image\"] :opts {:dir base-dir}}\n            {:cmd [(format \"%s/target/default+uberjar/swiza-graal\" base-dir)]}]))\n```\n\nYou will get output like:\n\n```clojure\n([\"drwxr-xr-x\" \"7\" \"bchoomnuan\" \"staff\" \"224\" \"Aug\" \"31\" \"11:01\" \".\"]\n [\"drwxr-xr-x\" \"60\" \"bchoomnuan\" \"staff\" \"1920\" \"Aug\" \"31\" \"09:22\" \"..\"]\n [\"-rw-r--r--\" \"1\" \"bchoomnuan\" \"staff\" \"5\" \"Aug\" \"31\" \"09:53\" \".nrepl-port\"]\n [\"-rw-r--r--\" \"1\" \"bchoomnuan\" \"staff\" \"1328\" \"Aug\" \"31\" \"11:01\" \"README.md\"]\n [\"-rw-r--r--\" \"1\" \"bchoomnuan\" \"staff\" \"2691\" \"Aug\" \"30\" \"22:56\" \"project.clj\"]\n [\"drwxr-xr-x\" \"4\" \"bchoomnuan\" \"staff\" \"128\" \"Aug\" \"23\" \"22:34\" \"src\"]\n [\"drwxr-xr-x\" \"4\" \"bchoomnuan\" \"staff\" \"128\" \"Aug\" \"24\" \"01:16\" \"target\"])\n```\n\nIf you like to post-process the result of a single output then try `sh-exec`\n\n```clojure\n(sh-exec [\"ls\" \"-al\"]\n         {:opts {:dir (expand-path \".\")}\n          :success-fn (fn [x]\n                        (if-let [lines (clojure.string/split x #\"\\n\")]\n                          (map #(clojure.string/split % #\"\\s+\") (rest lines))))})\n```\n\n```clojure\n;; More example\n(if-let [files (sh-exec [\"find\" (expand-path \"~/apps/pro-scripts\")\n                           \"-type\" \"f\"\n                           \"-iname\" \"*.sh\"]\n                          {:success-fn (fn [line]\n                                         (if-let [result (str/split line #\"\\n\")]\n                                           result))\n                           :opts {:dir (expand-path \"~/apps/pro-scripts\")}})]\n    (doseq [file files]\n      (println file)))\n```\n\n### Development\n\n```shell\ngit clone git@github.com:agilecreativity/swiza-sh.git\ncd swiza-sh \u0026\u0026 lein deps :tree\nlein repl\n;; then hackaway\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilecreativity%2Fswiza-sh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagilecreativity%2Fswiza-sh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilecreativity%2Fswiza-sh/lists"}