Coder Social home page Coder Social logo

conorsheehan1 / osxdocker Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 288 KB

A CLI for working with docker on OSX

Home Page: https://pypi.org/project/osxdocker/

License: MIT License

Python 97.35% Shell 2.65%
osx docker cli python pypi fire clear-logs poetry mac macos

osxdocker's Introduction

Build Status Documentation Status PyPI PyPI - License Code style: black

osxdocker

A CLI for working with docker on OSX

Currently it just handles docker logs, because I found it annoying starting up a screen session to get to the docker vm every time I wanted to clear logs. See: https://stackoverflow.com/questions/42527291/clear-logs-in-native-docker-on-mac

Install

# installs osxdocker and recommended docker and screen dependencies
brew install conorsheehan1/conorsheehan1/osxdocker

# installs osxdocker cli only, assumes you have docker and screen on your path
pip3 install osxdocker

Usage

# clear logs
osxdocker clear_log $some_container_name

# list available commands and flags
osxdocker

clear_log_example

This cli uses https://github.com/google/python-fire
Check out the docs for more details on usage, setting up bash completion, etc.
Also worth noting:

  1. Because the package uses fire, it can be imported like a normal python package. e.g.
    from osxdocker.docker_logs import DockerLogs
    DockerLogs().log_path('foo')
  2. This cli doesn't support --version due to a quirk with fire.
    osxdocker version # works fine
    osxdocker --version # won't work

Edge cases and gotchas

Container names are unique, but containers are filtered by regex, so you can still run into issues.
e.g. You have two containers, named foo and foo_too.
osxdocker cat_log foo will fail because it matches foo and foo_too.
osxdocker cat_log ^foo$ will work because it matches foo exactly.

multiple_container_error

Developer notes

See docs/source/dev.md

osxdocker's People

Contributors

conorsheehan1 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

osxdocker's Issues

Support id arg from cli

Most docker commands take an id or a name. e.g. docker logs
Currently (v0.1.2) osxdocker only supports names.

def clear_log(self, container_name):

I see two main options:

  1. Use one arg and figure out if it's a name or an id.

    def clear_logs(container_name_or_id):
        # this could be complicated / have edgecases. 
        # need to look into constraints for valid names and ids.
        if(container_name_or_id is name):
            # do something to convert to id
  2. Use 2 kwargs.
    Would make cli more verbose, but handle edgecases.
    e.g. osxdocker clear_log --name foo instead of osxdocker clear_log foo.

    def getContainerId(id=None, name=None):
        if (name):
            # do something to convert to id
        return id

Generate docs

  1. pydoc vs sphinx (chose sphinx)
  2. type annotations?
  3. add to readthedocs?

Add screenshots

Since I can't run the tests in CI, it'd be nice to show that it works. Even if it is only for a specific python and OSX version.

Split tests in unit and integration

  • Unit tests should be runnable without docker / screen (local and CI).
  • Integration tests require docker / screen , and won't be able to run on github actions until #5 is resolved.

Match docker API

Blocked until API is stable. Must close the following first:

  • major version change
  • update screenshots
  • match docker api:
    • cat_log -> logs
    • clear_log -> clear_logs
    • log_path -> logs_path

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.