<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Boško Ivanišević</title>
    <description>The latest articles on DEV Community by Boško Ivanišević (@bosko).</description>
    <link>https://dev.to/bosko</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F169694%2F0c4e65f0-bef4-4f21-bbdd-394f7371f47c.jpeg</url>
      <title>DEV Community: Boško Ivanišević</title>
      <link>https://dev.to/bosko</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bosko"/>
    <language>en</language>
    <item>
      <title>docker-cli Emacs package</title>
      <dc:creator>Boško Ivanišević</dc:creator>
      <pubDate>Sun, 26 May 2019 09:38:25 +0000</pubDate>
      <link>https://dev.to/bosko/docker-cli-emacs-package-53e7</link>
      <guid>https://dev.to/bosko/docker-cli-emacs-package-53e7</guid>
      <description>&lt;p&gt;Being Emacs user for a long time, I've finally decided to develop my&lt;br&gt;
first Emacs package and publish it on MELPA. Trigger was my recent&lt;br&gt;
move to Docker based development environment.&lt;/p&gt;

&lt;p&gt;Instead of installing various databases I've started using them&lt;br&gt;
through the Docker. This not only releived me from problems when I&lt;br&gt;
have to use various versions of the same database, but gave me&lt;br&gt;
possibility to quickly and easily switch to a new computer in very&lt;br&gt;
short time having exactly the same environment without too many&lt;br&gt;
hassle. Beside databases I've also dockerized Ruby on Rails&lt;br&gt;
development environment.&lt;/p&gt;

&lt;p&gt;With every component of development stack running in its own Docker&lt;br&gt;
container I frequently had to start shell in containers, run database&lt;br&gt;
commands line interfaces (psql, mysql, redis-cli), etc. Soon it became&lt;br&gt;
boring typing &lt;code&gt;docker-compose exec&lt;/code&gt; all the time and I decided to&lt;br&gt;
speed it up, so I made &lt;a href="https://github.com/bosko/docker-cli" rel="noopener noreferrer"&gt;docker-cli&lt;/a&gt; Emacs package.&lt;/p&gt;

&lt;p&gt;Package is relatively simple and comes with a small set of predefined&lt;br&gt;
commands for running shell, bash, psql, mysql or Redis clients within&lt;br&gt;
Emacs buffers.&lt;/p&gt;

&lt;p&gt;After calling interactive function &lt;code&gt;docker-cli&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;M-x docker-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;package asks for a command name that should be executed and the target&lt;br&gt;
Docker container both of which can be chosen from the list of&lt;br&gt;
available commands and a list of running containers&lt;br&gt;
respectively. After selecting both package, runs Docker command&lt;br&gt;
interactively with &lt;code&gt;docker exec -it&lt;/code&gt; and opens buffer with name made&lt;br&gt;
by concatenating command and container name.&lt;/p&gt;

&lt;p&gt;Package can be extended with new commands by adding new element to the&lt;br&gt;
&lt;code&gt;docker-cli-commands-alist&lt;/code&gt; list. Each element of the list must have&lt;br&gt;
following format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(COMMAND-KEY FEAUTRE VALUE)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where &lt;code&gt;COMMAND-KEY&lt;/code&gt; must be unique and is value that is listed on&lt;br&gt;
command auto-complete after executing &lt;code&gt;docker-cli&lt;/code&gt;. Only obligatory&lt;br&gt;
feature is &lt;code&gt;:command&lt;/code&gt; property which contains string that is actual&lt;br&gt;
command that will be executed in the container. Each &lt;code&gt;docker-cli&lt;/code&gt;&lt;br&gt;
command definition can define prompt structure (part of the buffer&lt;br&gt;
that Emacs will treat as read-only content) through two additional&lt;br&gt;
configuration parameters &lt;code&gt;:prompt-regexp&lt;/code&gt; and &lt;code&gt;:prompt-cont-regexp&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Docker commands can require different parameters like setting&lt;br&gt;
environment variable for &lt;code&gt;docker exec&lt;/code&gt;. This could be done through&lt;br&gt;
&lt;code&gt;:exec-arguments-func&lt;/code&gt; confguration parameter that, if needed,&lt;br&gt;
should keep a name of a function that will be executed and which&lt;br&gt;
should return full list of Docker command with all its arguments.&lt;/p&gt;

&lt;p&gt;Finally some commands might require additional arguments like &lt;code&gt;psql&lt;/code&gt;&lt;br&gt;
or &lt;code&gt;mysql&lt;/code&gt; that need user and database name. These arguments can be&lt;br&gt;
composed through last package configuration parameter&lt;br&gt;
&lt;code&gt;:arguments-compose-func&lt;/code&gt; which, if points to the function, will be&lt;br&gt;
used to gather command arguments before command is executed in the&lt;br&gt;
target container.&lt;/p&gt;

&lt;p&gt;This article is repost from &lt;a href="http://pragdevnotes.com/docker-cli-emacs-package/index.html" rel="noopener noreferrer"&gt;my blog&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>emacs</category>
      <category>lisp</category>
    </item>
  </channel>
</rss>
