Skip to content

Commit

Permalink
Working mepo completion (#325)
Browse files Browse the repository at this point in the history
* mepo completion doesn't require the extra mepo-path.py anymore

* Added option --location

* Using "mepo --location"

* Removed bin directory #322

* Updated CHANGALOG

* Updated CHANGALOG

* Include etc, bump minor version

* Fix test for version
  • Loading branch information
pchakraborty authored Oct 9, 2024
1 parent e8becd1 commit f54c6db
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Hidden option `--location` for mepo that returns the path to the mepo directory

### Changed

- Removed legacy `bin` directory

## [2.1.0] - 2024-10-02

### Fixed
Expand Down
17 changes: 0 additions & 17 deletions bin/mepo

This file was deleted.

7 changes: 1 addition & 6 deletions etc/mepo-completion.bash
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/usr/bin/env bash

# complete -W "init clone status checkout branch diff where whereis history" mepo

# SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SCRIPT_DIR=$(dirname $(realpath $0))

_get_mepo_commands() {
local mepo_cmd_list=""
local mepo_dir=$(python3 $SCRIPT_DIR/mepo-path.py)
local mepo_dir=$(mepo --location)
for pyfile in $(ls ${mepo_dir}/command/*.py*); do
command=${pyfile##*/} # remove path
command=${command%.*} # remove extension
Expand Down
3 changes: 0 additions & 3 deletions etc/mepo-path.py

This file was deleted.

7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mepo"
version = "2.1.0"
version = "2.2.0"
description = "A tool for managing (m)ultiple r(epo)s"
authors = [{name="GMAO SI Team", email="[email protected]"}]
dependencies = [
Expand Down Expand Up @@ -42,4 +42,7 @@ only_include = [
]

[tool.hatch.build.targets.wheel]
packages = ["src/mepo"]
packages = [
"etc",
"src/mepo",
]
16 changes: 16 additions & 0 deletions src/mepo/cmdline/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ def get_version():
return metadata.version("mepo")


class LocationAction(argparse._StoreTrueAction):

def __init__(self, option_strings, dest, const=True, help=None):
super().__init__(option_strings, dest, const, help=help)

def __call__(self, parser, namespace, values, option_string=None):
import os, sys
import mepo

print(os.path.dirname(mepo.__file__))
sys.exit(0)


class MepoArgParser:

__slots__ = ["parser", "subparsers"]
Expand All @@ -23,6 +36,9 @@ def __init__(self):
description="Tool to manage (m)ultiple r(epo)s"
)
self.parser.add_argument("--version", action="version", version=get_version())
self.parser.add_argument(
"--location", action=LocationAction, help=argparse.SUPPRESS
)
self.subparsers = self.parser.add_subparsers()
self.subparsers.title = "mepo commands"
self.subparsers.required = True
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mepo_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def test_reset(self):
self.__class__.__mepo_clone()

def test_mepo_version(self):
self.assertEqual(get_mepo_version(), "2.1.0")
self.assertEqual(get_mepo_version(), "2.2.0")

def tearDown(self):
pass
Expand Down

0 comments on commit f54c6db

Please sign in to comment.