zsh-users
 help / color / mirror / code / Atom feed
* Feature request: a command launcher
@ 2017-12-18  9:39 Sebastian Gniazdowski
  2017-12-18 14:57 ` Sebastian Gniazdowski
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Gniazdowski @ 2017-12-18  9:39 UTC (permalink / raw)
  To: Zsh Users

Hello

I came up with a feature that could be called "services". It's about defining a widely understood environment for a specified command. The point is that "environment" doesn't only mean: exported variables, but also: redirections, working directory, use of sudo, command arguments, etc. Present solutions like direnv/direnv handle only environment variables.

A definition of service could look like this:

#
# Definition of a service that builds Zsh located at
# ~/github/sfzsh3, with -O2 and pointers to libgdbm.
#
# This file is for configure script. File sfzsh3make
# is for running make, and is triggered automatically
# by this file
#

integer disabled=0
local command="./configure"

local arguments='--enable-unicode9'
integer spawn_type=0        # available: disown, fork, subshell, coproc, zpty, nohup;
                            # can combine to some extent, e.g. $(( fork | disown ))
integer run_method=command  # available: command, autofun, source

local stdin=""              # no redirection
local stdout="/dev/null"
local stderr=""

integer sudo=0
local run_first=""          # no service to run first
local run_last="sfzsh3make" # run sfzsh3make after this service

local workdir="$HOME/github/sfzsh3"
integer cd=1                # stay in $workdir after this service finishes

local -A env
env=(
    CFLAGS      "-g -Wall -O2"
    CPPFLAGS    "-I/usr/local/include"
    LDFLAGS     "-L/usr/local/lib"
)

Then, to compile Zsh, one would issue: zsrv build_sfzsh3. "zsrv" is hard to type, the name should be better.

Someone might ask: why not create a script that holds complete configure command and make invocation. So why e.g. OS X does the definition-way for its services, it could just create and collect scripts ;) I'll limit to just this: the definition is just a series of parameter assignments, it's like separating data from presentation (XML vs. HTML). All this is a subtle, but still a paradigm-shift.

I'm worried about how many use cases would this have. Above "Zsh building that doesn't need history-dig, cd and parsing 'is it -O0 or -O2, what did I run last time'" is a good use case. But are there more use cases, has someone ideas?

I came up with this idea for Zplugin, but decided to ask in feature-request style, because I really think that Zsh would gain from such feature. And I'm curious of possible code and alterations. But I also need feedback if this looks useful or not.

--  
Sebastian Gniazdowski
psprint /at/ zdharma.org


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Feature request: a command launcher
  2017-12-18  9:39 Feature request: a command launcher Sebastian Gniazdowski
@ 2017-12-18 14:57 ` Sebastian Gniazdowski
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Gniazdowski @ 2017-12-18 14:57 UTC (permalink / raw)
  To: Zsh Users

On 18 Dec 2017 at 10:39:33, Sebastian Gniazdowski (psprint@zdharma.org) wrote:
> I came up with this idea for Zplugin, but decided to ask in feature-request style, because  
> I really think that Zsh would gain from such feature. And I'm curious of possible code  
> and alterations. But I also need feedback if this looks useful or not.

Found other use-case:

- 'zplugin self-update' downloads new *zplugin* commits and *doesn't* list them like in case of updating a plugin
- the goal: list new zplugin commits, then merge
- the created service is to be named 'self-update'
- user is to run: 'zplugin run self-update', not 'zplugin self-update'
- definition of the service could look like this:

    integer disabled=0
    local command="git fetch; git log ..FETCH_HEAD; zplugin self-update"
    local arguments=";--oneline;"
    local spawn_type=";;"  # default, via eval, no forking, etc.
    local run_method="command;command;function"
    local work_dir="${ZPLGM[BIN_DIR]}"  # zplugin fills this
    integer cd=0  # don't stay in zplugin's directory, go back

I skipped redirections, environment, sudo, etc., those fields should be empty.

I could even ship this service with zplugin. For me, when I compare shipping a script (like say self-update.zsh) vs. shipping a definition, it's clear that the script route gives impression like if user should run someone's joyful creativity done during a single weekend and this is very repulsive. I think the amount of attention given to contributed or helper scripts is low in great majority of projects, and users may think the same.

The service definition route, on the other hand, seems to be very solid. Altering the definition doesn't give impression that a mistake can easily be made. It looks like zplugin has a sharp subsystem that allows to be driven by a few assignments. There are not many points of freedom, and the subsystem is expected to be bug-free, maintained.

--  
Sebastian Gniazdowski
psprint /at/ zdharma.org


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-18 14:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-18  9:39 Feature request: a command launcher Sebastian Gniazdowski
2017-12-18 14:57 ` Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).