dploy 0.1.2__tar.gz → 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. dploy-0.1.3/PKG-INFO +78 -0
  2. {dploy-0.1.2 → dploy-0.1.3}/README.md +63 -58
  3. {dploy-0.1.2 → dploy-0.1.3}/dploy/__init__.py +35 -35
  4. {dploy-0.1.2 → dploy-0.1.3}/dploy/__main__.py +17 -19
  5. {dploy-0.1.2 → dploy-0.1.3}/dploy/actions.py +16 -12
  6. dploy-0.1.3/dploy/cli.py +114 -0
  7. {dploy-0.1.2 → dploy-0.1.3}/dploy/error.py +71 -29
  8. {dploy-0.1.2 → dploy-0.1.3}/dploy/ignore.py +2 -2
  9. {dploy-0.1.2 → dploy-0.1.3}/dploy/linkcmd.py +17 -23
  10. {dploy-0.1.2 → dploy-0.1.3}/dploy/main.py +4 -6
  11. {dploy-0.1.2 → dploy-0.1.3}/dploy/stowcmd.py +116 -50
  12. {dploy-0.1.2 → dploy-0.1.3}/dploy/utils.py +123 -105
  13. dploy-0.1.3/dploy/version.py +5 -0
  14. dploy-0.1.3/pyproject.toml +36 -0
  15. dploy-0.1.2/.pylintrc +0 -7
  16. dploy-0.1.2/CHANGELOG.md +0 -161
  17. dploy-0.1.2/MANIFEST.in +0 -12
  18. dploy-0.1.2/PKG-INFO +0 -76
  19. dploy-0.1.2/conftest.py +0 -0
  20. dploy-0.1.2/dploy/__init__.py.orig +0 -45
  21. dploy-0.1.2/dploy/__init__.pyc +0 -0
  22. dploy-0.1.2/dploy/__pycache__/__init__.cpython-35.pyc +0 -0
  23. dploy-0.1.2/dploy/__pycache__/__init__.cpython-36.pyc +0 -0
  24. dploy-0.1.2/dploy/__pycache__/__main__.cpython-35.pyc +0 -0
  25. dploy-0.1.2/dploy/__pycache__/__main__.cpython-36.pyc +0 -0
  26. dploy-0.1.2/dploy/__pycache__/actions.cpython-35.pyc +0 -0
  27. dploy-0.1.2/dploy/__pycache__/actions.cpython-36.pyc +0 -0
  28. dploy-0.1.2/dploy/__pycache__/cli.cpython-35.pyc +0 -0
  29. dploy-0.1.2/dploy/__pycache__/cli.cpython-36.pyc +0 -0
  30. dploy-0.1.2/dploy/__pycache__/error.cpython-35.pyc +0 -0
  31. dploy-0.1.2/dploy/__pycache__/error.cpython-36.pyc +0 -0
  32. dploy-0.1.2/dploy/__pycache__/ignore.cpython-35.pyc +0 -0
  33. dploy-0.1.2/dploy/__pycache__/ignore.cpython-36.pyc +0 -0
  34. dploy-0.1.2/dploy/__pycache__/linkcmd.cpython-35.pyc +0 -0
  35. dploy-0.1.2/dploy/__pycache__/linkcmd.cpython-36.pyc +0 -0
  36. dploy-0.1.2/dploy/__pycache__/main.cpython-35.pyc +0 -0
  37. dploy-0.1.2/dploy/__pycache__/main.cpython-36.pyc +0 -0
  38. dploy-0.1.2/dploy/__pycache__/stowcmd.cpython-35.pyc +0 -0
  39. dploy-0.1.2/dploy/__pycache__/stowcmd.cpython-36.pyc +0 -0
  40. dploy-0.1.2/dploy/__pycache__/utils.cpython-35.pyc +0 -0
  41. dploy-0.1.2/dploy/__pycache__/utils.cpython-36.pyc +0 -0
  42. dploy-0.1.2/dploy/__pycache__/version.cpython-35.pyc +0 -0
  43. dploy-0.1.2/dploy/__pycache__/version.cpython-36.pyc +0 -0
  44. dploy-0.1.2/dploy/cli.py +0 -101
  45. dploy-0.1.2/dploy/version.py +0 -18
  46. dploy-0.1.2/dploy.egg-info/PKG-INFO +0 -76
  47. dploy-0.1.2/dploy.egg-info/SOURCES.txt +0 -73
  48. dploy-0.1.2/dploy.egg-info/dependency_links.txt +0 -1
  49. dploy-0.1.2/dploy.egg-info/entry_points.txt +0 -3
  50. dploy-0.1.2/dploy.egg-info/top_level.txt +0 -1
  51. dploy-0.1.2/invoke.yaml +0 -2
  52. dploy-0.1.2/requirements.txt +0 -10
  53. dploy-0.1.2/setup.cfg +0 -8
  54. dploy-0.1.2/setup.py +0 -41
  55. dploy-0.1.2/tasks.py +0 -108
  56. dploy-0.1.2/tests/__pycache__/conftest.cpython-35-PYTEST.pyc +0 -0
  57. dploy-0.1.2/tests/__pycache__/conftest.cpython-36-PYTEST.pyc +0 -0
  58. dploy-0.1.2/tests/__pycache__/conftest.cpython-36.pyc +0 -0
  59. dploy-0.1.2/tests/__pycache__/test_cli.cpython-35-PYTEST.pyc +0 -0
  60. dploy-0.1.2/tests/__pycache__/test_cli.cpython-36-PYTEST.pyc +0 -0
  61. dploy-0.1.2/tests/__pycache__/test_ignore.cpython-35-PYTEST.pyc +0 -0
  62. dploy-0.1.2/tests/__pycache__/test_ignore.cpython-36-PYTEST.pyc +0 -0
  63. dploy-0.1.2/tests/__pycache__/test_link.cpython-35-PYTEST.pyc +0 -0
  64. dploy-0.1.2/tests/__pycache__/test_link.cpython-36-PYTEST.pyc +0 -0
  65. dploy-0.1.2/tests/__pycache__/test_stow.cpython-35-PYTEST.pyc +0 -0
  66. dploy-0.1.2/tests/__pycache__/test_stow.cpython-36-PYTEST.pyc +0 -0
  67. dploy-0.1.2/tests/__pycache__/test_unstow.cpython-35-PYTEST.pyc +0 -0
  68. dploy-0.1.2/tests/__pycache__/test_unstow.cpython-36-PYTEST.pyc +0 -0
  69. dploy-0.1.2/tests/__pycache__/utils.cpython-35.pyc +0 -0
  70. dploy-0.1.2/tests/__pycache__/utils.cpython-36.pyc +0 -0
  71. dploy-0.1.2/tests/conftest.py +0 -173
  72. dploy-0.1.2/tests/test_cli.py +0 -84
  73. dploy-0.1.2/tests/test_ignore.py +0 -40
  74. dploy-0.1.2/tests/test_link.py +0 -67
  75. dploy-0.1.2/tests/test_stow.py +0 -232
  76. dploy-0.1.2/tests/test_unstow.py +0 -228
  77. dploy-0.1.2/tests/utils.py +0 -101
  78. {dploy-0.1.2 → dploy-0.1.3}/LICENSE.txt +0 -0
dploy-0.1.3/PKG-INFO ADDED
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: dploy
3
+ Version: 0.1.3
4
+ Summary: Provides functionality similar to GNU Stow as a cross platform CLI tool and Python 3 module
5
+ License-Expression: MIT
6
+ License-File: LICENSE.txt
7
+ Author: Ryan Carney
8
+ Author-email: arecarn@gmail.com
9
+ Requires-Python: >=3.10
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Topic :: Utilities
12
+ Project-URL: Homepage, https://github.com/arecarn/dploy
13
+ Description-Content-Type: text/markdown
14
+
15
+ # Dploy
16
+
17
+ Dploy is a tool for creating symbolic links similarly to [GNU
18
+ Stow](https://www.gnu.org/software/stow/). It is provided as a CLI tool and
19
+ Python 3.10+ module and supports Windows, Linux, and OSX.
20
+
21
+ Dploy's command `stow` creates symbolic links to the contents of source
22
+ directories or packages in a specified destination directory. Repeating the
23
+ `stow` command with the same arguments will confirm that the contents of the
24
+ package have been symbolically linked.
25
+
26
+ Dploy's command `unstow` removes symbolic links that resulted from `stow`
27
+ commands. Repeating the `unstow` command with the same arguments will confirm
28
+ that the links to stowed packages have been removed.
29
+
30
+ ## Installation
31
+
32
+ * Latest Release: `pip install dploy`
33
+ * Development Version: `pip install git+https://github.com/arecarn/dploy.git`
34
+
35
+ ## Basic CLI Usage
36
+
37
+ * `dploy stow <source-directory>... <destination-directory>`
38
+ * `dploy unstow <source-directory>... <destination-directory>`
39
+ * `dploy clean <source-directory>... <destination-directory>`
40
+ * `dploy --help`
41
+
42
+ ## Rationale
43
+
44
+ Dploy started out as simple Python script to create symbolic links to my
45
+ dotfiles for Windows, Mac, and Linux. Over time I keep improving and tweaking my
46
+ script to suit my needs, but I was running into a problem. Keeping all the
47
+ files I wanted to link in a config file was becoming a real pain in the neck.
48
+
49
+ I started looking for another solution to solve my problem, and found many
50
+ alternatives but none of them seemed to be a good fit. The solution that seemed
51
+ the most promising was using GNU Stow. It seemed like the most simple elegant
52
+ solution to the problem. The only issue was that it didn't support Windows.
53
+
54
+ Then I thought to myself, why can't I just create my own version of Stow that
55
+ work on Windows, Linux and OSX. So after that my I started morphing
56
+ simple python script into what would become Dploy and learned a lot more about
57
+ python in the process.
58
+
59
+ ## How does it compare with GNU Stow?
60
+
61
+ Below are just a few few major points of comparison between GNU stow and Dploy.
62
+
63
+ * Like GNU Stow Dploy runs in two passes. First by collecting the actions
64
+ required to complete the command and verifying that the command can
65
+ completed without any issues. If no issues are detected then the second
66
+ pass executes these actions are execute to complete the command. Otherwise
67
+ Dploy will exit and indicate why the command can not be completed. This way a
68
+ stow or unstow operation is atomic and never partially done.
69
+
70
+ * Like Stow, Dploy supports tree folding and tree unfolding.
71
+
72
+ * Unlike Stow, Dploy requires an explicit source(s) and a destination
73
+ directory.
74
+
75
+ * Unlike Stow, Dploy does not have any concept of ownership, but will only
76
+ operate on symbolic links and the creation or removal of directories for these
77
+ symbolic links.
78
+
@@ -1,58 +1,63 @@
1
- # Dploy
2
-
3
- Dploy is a tool for creating symbolic links similarly to [GNU
4
- Stow](https://www.gnu.org/software/stow/). It is provided as a CLI tool and
5
- Python 3.3+ module and supports Windows, Linux, and OSX.
6
-
7
- Dploy's command `stow` creates symbolic links to the contents of source
8
- directories or packages in a specified destination directory. Repeating the
9
- `stow` command with the same arguments will confirm that the contents of the
10
- package have been symbolically linked.
11
-
12
- Dploy's command `unstow` removes symbolic links that resulted from `stow`
13
- commands. Repeating the `unstow` command with the same arguments will confirm
14
- that the links to stowed packages have been removed.
15
-
16
- ## Installation
17
- * Latest Release: `pip install dploy`
18
- * Development Version: `pip install git+https://github.com/arecarn/dploy.git`
19
-
20
- ## Basic CLI Usage
21
- * `dploy stow <source-directory>... <destination-directory>`
22
- * `dploy unstow <source-directory>... <destination-directory>`
23
- * `dploy --help`
24
-
25
- ## Rational
26
- Dploy started out as simple Python script to create symbolic links to my
27
- dotfiles for Windows, Mac, and Linux. Over time I keep improving and tweaking my
28
- script to suit my needs, but I was running into a problem. Keeping all the
29
- files I wanted to link in a config file was becoming a real pain in the neck.
30
-
31
- I started looking for another solution to solve my problem, and found many
32
- alternatives but none of them seemed to be a good fit. The solution that seemed
33
- the most promising was using GNU Stow. It seemed like the most simple elegant
34
- solution to the problem. The only issue was that it didn't support Windows.
35
-
36
- Then I thought to myself, why can't I just create my own version of Stow that
37
- work on Windows, Linux and OSX. So after that my I started morphing
38
- simple python script into what would become Dploy and learned a lot more about
39
- python in the process.
40
-
41
- ## How does it compare with GNU Stow?
42
- Below are just a few few major points of comparison between GNU stow and Dploy.
43
-
44
- - Like GNU Stow Dploy runs in two passes. First by collecting the actions
45
- required to complete the command and verifying that the command can
46
- completed without any issues. If no issues are detected then the second
47
- pass executes these actions are execute to complete the command. Otherwise
48
- Dploy will exit and indicate why the command can not be completed. This way a
49
- stow or unstow operation is atomic and never partially done.
50
-
51
- - Like Stow, Dploy supports tree folding and tree unfolding.
52
-
53
- - Unlike Stow, Dploy requires an explicit source(s) and a destination
54
- directory.
55
-
56
- - Unlike Stow, Dploy does not have any concept of ownership, but will only
57
- operate on symbolic links and the creation or removal of directories for these
58
- symbolic links.
1
+ # Dploy
2
+
3
+ Dploy is a tool for creating symbolic links similarly to [GNU
4
+ Stow](https://www.gnu.org/software/stow/). It is provided as a CLI tool and
5
+ Python 3.10+ module and supports Windows, Linux, and OSX.
6
+
7
+ Dploy's command `stow` creates symbolic links to the contents of source
8
+ directories or packages in a specified destination directory. Repeating the
9
+ `stow` command with the same arguments will confirm that the contents of the
10
+ package have been symbolically linked.
11
+
12
+ Dploy's command `unstow` removes symbolic links that resulted from `stow`
13
+ commands. Repeating the `unstow` command with the same arguments will confirm
14
+ that the links to stowed packages have been removed.
15
+
16
+ ## Installation
17
+
18
+ * Latest Release: `pip install dploy`
19
+ * Development Version: `pip install git+https://github.com/arecarn/dploy.git`
20
+
21
+ ## Basic CLI Usage
22
+
23
+ * `dploy stow <source-directory>... <destination-directory>`
24
+ * `dploy unstow <source-directory>... <destination-directory>`
25
+ * `dploy clean <source-directory>... <destination-directory>`
26
+ * `dploy --help`
27
+
28
+ ## Rationale
29
+
30
+ Dploy started out as simple Python script to create symbolic links to my
31
+ dotfiles for Windows, Mac, and Linux. Over time I keep improving and tweaking my
32
+ script to suit my needs, but I was running into a problem. Keeping all the
33
+ files I wanted to link in a config file was becoming a real pain in the neck.
34
+
35
+ I started looking for another solution to solve my problem, and found many
36
+ alternatives but none of them seemed to be a good fit. The solution that seemed
37
+ the most promising was using GNU Stow. It seemed like the most simple elegant
38
+ solution to the problem. The only issue was that it didn't support Windows.
39
+
40
+ Then I thought to myself, why can't I just create my own version of Stow that
41
+ work on Windows, Linux and OSX. So after that my I started morphing
42
+ simple python script into what would become Dploy and learned a lot more about
43
+ python in the process.
44
+
45
+ ## How does it compare with GNU Stow?
46
+
47
+ Below are just a few few major points of comparison between GNU stow and Dploy.
48
+
49
+ * Like GNU Stow Dploy runs in two passes. First by collecting the actions
50
+ required to complete the command and verifying that the command can
51
+ completed without any issues. If no issues are detected then the second
52
+ pass executes these actions are execute to complete the command. Otherwise
53
+ Dploy will exit and indicate why the command can not be completed. This way a
54
+ stow or unstow operation is atomic and never partially done.
55
+
56
+ * Like Stow, Dploy supports tree folding and tree unfolding.
57
+
58
+ * Unlike Stow, Dploy requires an explicit source(s) and a destination
59
+ directory.
60
+
61
+ * Unlike Stow, Dploy does not have any concept of ownership, but will only
62
+ operate on symbolic links and the creation or removal of directories for these
63
+ symbolic links.
@@ -1,35 +1,35 @@
1
- """
2
- dploy script is an attempt at creating a clone of GNU stow that will work on
3
- Windows as well as *nix
4
- """
5
-
6
- import sys
7
- from dploy import linkcmd
8
- from dploy import stowcmd
9
- assert sys.version_info >= (3, 3), "Requires Python 3.3 or Greater"
10
-
11
-
12
- def stow(sources, dest, is_silent=True, is_dry_run=False,
13
- ignore_patterns=None):
14
- """
15
- sub command stow
16
- """
17
- stowcmd.Stow(sources, dest, is_silent, is_dry_run, ignore_patterns)
18
-
19
-
20
- def unstow(sources,
21
- dest,
22
- is_silent=True,
23
- is_dry_run=False,
24
- ignore_patterns=None):
25
- """
26
- sub command unstow
27
- """
28
- stowcmd.UnStow(sources, dest, is_silent, is_dry_run, ignore_patterns)
29
-
30
-
31
- def link(source, dest, is_silent=True, is_dry_run=False, ignore_patterns=None):
32
- """
33
- sub command link
34
- """
35
- linkcmd.Link(source, dest, is_silent, is_dry_run, ignore_patterns)
1
+ """
2
+ dploy script is an attempt at creating a clone of GNU stow that will work on
3
+ Windows as well as *nix
4
+ """
5
+
6
+ from dploy import linkcmd
7
+ from dploy import stowcmd
8
+
9
+
10
+ def stow(sources, dest, is_silent=True, is_dry_run=False, ignore_patterns=None):
11
+ """
12
+ sub command stow
13
+ """
14
+ stowcmd.Stow(sources, dest, is_silent, is_dry_run, ignore_patterns)
15
+
16
+
17
+ def unstow(sources, dest, is_silent=True, is_dry_run=False, ignore_patterns=None):
18
+ """
19
+ sub command unstow
20
+ """
21
+ stowcmd.UnStow(sources, dest, is_silent, is_dry_run, ignore_patterns)
22
+
23
+
24
+ def clean(sources, dest, is_silent=True, is_dry_run=False, ignore_patterns=None):
25
+ """
26
+ sub command clean
27
+ """
28
+ stowcmd.Clean(sources, dest, is_silent, is_dry_run, ignore_patterns)
29
+
30
+
31
+ def link(source, dest, is_silent=True, is_dry_run=False, ignore_patterns=None):
32
+ """
33
+ sub command link
34
+ """
35
+ linkcmd.Link(source, dest, is_silent, is_dry_run, ignore_patterns)
@@ -1,19 +1,17 @@
1
- #!/usr/bin/env python3
2
- """
3
- The entry point when dploy is called as a module
4
- """
5
-
6
- import sys
7
- from dploy import cli
8
- assert sys.version_info >= (3, 3), "Requires Python 3.3 or Greater"
9
-
10
-
11
- def main():
12
- """
13
- main entry point when using dploy from the command line
14
- """
15
- cli.run()
16
-
17
-
18
- if __name__ == '__main__':
19
- main()
1
+ #!/usr/bin/env python3
2
+ """
3
+ The entry point when dploy is called as a module
4
+ """
5
+
6
+ from dploy import cli
7
+
8
+
9
+ def main():
10
+ """
11
+ main entry point when using dploy from the command line
12
+ """
13
+ cli.run()
14
+
15
+
16
+ if __name__ == "__main__":
17
+ main()
@@ -7,7 +7,7 @@ from collections import defaultdict
7
7
  from dploy import utils
8
8
 
9
9
 
10
- class Actions():
10
+ class Actions:
11
11
  """
12
12
  A class that collects and executes action objects
13
13
  """
@@ -66,11 +66,10 @@ class Actions():
66
66
  if isinstance(action, SymbolicLink):
67
67
  tally[action.dest].append(index)
68
68
  # sort for deterministic output
69
- return sorted(
70
- [indices for _, indices in tally.items() if len(indices) > 1])
69
+ return sorted([indices for _, indices in tally.items() if len(indices) > 1])
71
70
 
72
71
 
73
- class AbstractBaseAction():
72
+ class AbstractBaseAction:
74
73
  # pylint: disable=too-few-public-methods
75
74
  """
76
75
  An abstract base class that define the interface for actions
@@ -104,7 +103,8 @@ class SymbolicLink(AbstractBaseAction):
104
103
 
105
104
  def __repr__(self):
106
105
  return "dploy {subcmd}: link {dest} => {source}".format(
107
- subcmd=self.subcmd, dest=self.dest, source=self.source_relative)
106
+ subcmd=self.subcmd, dest=self.dest, source=self.source_relative
107
+ )
108
108
 
109
109
 
110
110
  class AlreadyLinked(AbstractBaseAction):
@@ -125,7 +125,8 @@ class AlreadyLinked(AbstractBaseAction):
125
125
 
126
126
  def __repr__(self):
127
127
  return "dploy {subcmd}: already linked {dest} => {source}".format(
128
- subcmd=self.subcmd, source=self.source_relative, dest=self.dest)
128
+ subcmd=self.subcmd, source=self.source_relative, dest=self.dest
129
+ )
129
130
 
130
131
 
131
132
  class AlreadyUnlinked(AbstractBaseAction):
@@ -146,7 +147,8 @@ class AlreadyUnlinked(AbstractBaseAction):
146
147
 
147
148
  def __repr__(self):
148
149
  return "dploy {subcmd}: already unlinked {dest} => {source}".format(
149
- subcmd=self.subcmd, source=self.source_relative, dest=self.dest)
150
+ subcmd=self.subcmd, source=self.source_relative, dest=self.dest
151
+ )
150
152
 
151
153
 
152
154
  class UnLink(AbstractBaseAction):
@@ -164,15 +166,16 @@ class UnLink(AbstractBaseAction):
164
166
  if not self.target.is_symlink():
165
167
  # pylint: disable=line-too-long
166
168
  raise RuntimeError(
167
- 'dploy detected and aborted an attempt to unlink a non-symlink this is a bug and should be reported'
169
+ "dploy detected and aborted an attempt to unlink a non-symlink {target} this is a bug and should be reported".format(
170
+ target=self.target
171
+ )
168
172
  )
169
173
  self.target.unlink()
170
174
 
171
175
  def __repr__(self):
172
- source_relative = utils.get_relative_path(self.target.resolve(),
173
- self.target.parent)
174
176
  return "dploy {subcmd}: unlink {target} => {source}".format(
175
- subcmd=self.subcmd, target=self.target, source=source_relative)
177
+ subcmd=self.subcmd, target=self.target, source=utils.readlink(self.target)
178
+ )
176
179
 
177
180
 
178
181
  class MakeDirectory(AbstractBaseAction):
@@ -191,7 +194,8 @@ class MakeDirectory(AbstractBaseAction):
191
194
 
192
195
  def __repr__(self):
193
196
  return "dploy {subcmd}: make directory {target}".format(
194
- target=self.target, subcmd=self.subcmd)
197
+ target=self.target, subcmd=self.subcmd
198
+ )
195
199
 
196
200
 
197
201
  class RemoveDirectory(AbstractBaseAction):
@@ -0,0 +1,114 @@
1
+ """
2
+ The command line interface
3
+ """
4
+
5
+ import sys
6
+ import argparse
7
+ from dploy import linkcmd
8
+ from dploy import stowcmd
9
+ from dploy import version
10
+ from dploy.error import DployError
11
+
12
+
13
+ def add_ignore_argument(parser):
14
+ """
15
+ adds the ignore argument to a subcmd parser
16
+ """
17
+ parser.add_argument(
18
+ "--ignore",
19
+ dest="ignore_patterns",
20
+ action="append",
21
+ default=None,
22
+ help="glob pattern used to ignore directories",
23
+ )
24
+
25
+
26
+ def create_parser():
27
+ """
28
+ create the CLI argument parser
29
+ """
30
+ parser = argparse.ArgumentParser(prog="dploy")
31
+
32
+ parser.add_argument(
33
+ "--version",
34
+ action="version",
35
+ version="%(prog)s {version}".format(version=version.__version__),
36
+ )
37
+ parser.add_argument(
38
+ "--silent", dest="is_silent", action="store_true", help="suppress all output"
39
+ )
40
+ parser.add_argument(
41
+ "--dry-run",
42
+ dest="is_dry_run",
43
+ action="store_true",
44
+ help="show what would be done without doing it",
45
+ )
46
+
47
+ sub_parsers = parser.add_subparsers(dest="subcmd")
48
+
49
+ stow_parser = sub_parsers.add_parser("stow")
50
+ stow_parser.add_argument("source", nargs="+", help="source directory to stow")
51
+ stow_parser.add_argument("dest", help="destination path to stow into")
52
+ add_ignore_argument(stow_parser)
53
+
54
+ unstow_parser = sub_parsers.add_parser("unstow")
55
+ unstow_parser.add_argument(
56
+ "source", nargs="+", help="source directory to unstow from"
57
+ )
58
+ unstow_parser.add_argument("dest", help="destination path to unstow")
59
+ add_ignore_argument(unstow_parser)
60
+
61
+ clean_parser = sub_parsers.add_parser("clean")
62
+ clean_parser.add_argument(
63
+ "source", nargs="+", help="source directory to clean from"
64
+ )
65
+ clean_parser.add_argument("dest", help="destination path to clean")
66
+ add_ignore_argument(clean_parser)
67
+
68
+ link_parser = sub_parsers.add_parser("link")
69
+ link_parser.add_argument("source", help="source file or directory to link")
70
+ link_parser.add_argument("dest", help="destination path to link")
71
+ add_ignore_argument(link_parser)
72
+ return parser
73
+
74
+
75
+ def run(arguments=None):
76
+ """
77
+ interpret the parser arguments and execute the corresponding commands
78
+ """
79
+
80
+ subcmd_map = {
81
+ "stow": stowcmd.Stow,
82
+ "unstow": stowcmd.UnStow,
83
+ "clean": stowcmd.Clean,
84
+ "link": linkcmd.Link,
85
+ }
86
+
87
+ try:
88
+ parser = create_parser()
89
+
90
+ if arguments is None:
91
+ args = parser.parse_args()
92
+ else:
93
+ args = parser.parse_args(arguments)
94
+
95
+ if args.subcmd in subcmd_map:
96
+ subcmd = subcmd_map[args.subcmd]
97
+ else:
98
+ parser.print_help()
99
+ sys.exit(0)
100
+
101
+ try:
102
+ subcmd(
103
+ args.source,
104
+ args.dest,
105
+ is_silent=args.is_silent,
106
+ is_dry_run=args.is_dry_run,
107
+ ignore_patterns=args.ignore_patterns,
108
+ )
109
+ except DployError:
110
+ sys.exit(1)
111
+
112
+ except (KeyboardInterrupt) as error:
113
+ print(error, file=sys.stderr)
114
+ sys.exit(130)