Giter Club home page Giter Club logo

Comments (7)

tony avatar tony commented on May 25, 2024

kwargs weren't intended to be supported like that in current / prior versions.

kwargs it only there to pick up tmux_search_paths and append_env_path. Other than that, any instances of kwargs entering tmux_cmd are a bug.

That said, I have no objection to adding it if it makes the experience more consistent / pleasant. However, I did want the signature on tmux_cmd to be similar to subprocess' signature.

When I written the tmux_cmd object, it was inspired by subprocess code in saltstack and pip (circa 2012/2013).

To play a bit of devil's advocate in terms of an intuitive, pythonic API: Do you know any other python subprocess-like (command) libraries that accept command line flags as kwargs?

from libtmux.

tony avatar tony commented on May 25, 2024

It does seem big that kwargs = {u'-t': u'$8'} is being passed into tmux_cmd.

Think we could smoosh that back into args?

from libtmux.

askedrelic avatar askedrelic commented on May 25, 2024

Thanks for the context and quick reply Tony! So args should contain multiple values, as a proper list. I agree that kwargs seems more optional or should be used for internal flags.

For your 2nd comment, about changing the Session.cmd call? https://github.com/tony/libtmux/blob/master/libtmux/session.py#L75,L77

args = ['set-environment']
if '-t' not in args:
    args.extend(['-t', self.id])

# args = ['set-environment', '-t', 'id']

This should probably not break backwards compatibility too much; it seems better to explicitly include the session id.

from libtmux.

tony avatar tony commented on May 25, 2024

Yes that's on the right track

Even better, args += ['-t', self.id] (https://stackoverflow.com/questions/4176980/is-extend-faster-than)

I agree that kwargs seems more optional or should be used for internal flags.

It may be worth to put a comment in there that **kwargs was only put for those options.

As an aside (not for right now): When I wrote this, I wanted to have a signature for commands like tmux_cmd('list-panes', '-a'). After reflection, it sort of complicated the code. In the future, we may want to change the signature entirely to rely on a list variable instead of *args*. 1. because using *argsmeans we can't use named keyword arguments. and 2. passing in the command (e.g.['list-sessions']``) as a list is closer to subprocess' signatures. Which is probably going to be more intuitive to python programmers since that's the style used in the standard library.

from libtmux.

tony avatar tony commented on May 25, 2024

This should probably not break backwards compatibility too much; it seems better to explicitly include the session id.

The test suite is pretty solid. It tests against tmux itself and has enough coverage there's room to do internal refactors in the future (e.g. normalizing the tmux_cmd argument signature to be more consistent with subprocess')

from libtmux.

tony avatar tony commented on May 25, 2024

#65 is merged.

from libtmux.

askedrelic avatar askedrelic commented on May 25, 2024

Closing since #65 was the outcome.

We did not include kwargs in tmux_cmd, but made a more targeted fix in Session.cmd()

from libtmux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.