@@ -41,7 +41,7 @@ pip3 install buildme
41
41
``` python
42
42
# !/bin/env buildme
43
43
from argparse import Namespace # for type hinting purposes only
44
- from buildme import CommandRunner
44
+ from buildme import CommandRunner, target
45
45
46
46
47
47
cr = CommandRunner(
@@ -55,17 +55,33 @@ cr = CommandRunner(
55
55
# method CommandRunner.set_exit_non_zero(vel: bool)
56
56
57
57
58
- def hello (opts : Namespace):
58
+ @target (depends = [' test' ])
59
+ def hello (opts : Namespace, _ ):
59
60
print (opts)
60
61
code = cr.run(' echo Hello World' )
61
62
print (f ' { code= } ' )
62
63
63
64
64
- def test (opts : Namespace):
65
- if opts.release == ' 0' :
65
+ @target ()
66
+ def test (opts : Namespace, _ ):
67
+ if getattr (opts, ' release' , None ) is not None and opts.release == ' 0' :
66
68
print (' release is zero' )
67
69
print (' This from test' )
68
70
71
+
72
+ @target ()
73
+ def foo (_ , __ ):
74
+ print (' This is the foo target' )
75
+
76
+
77
+ @target ()
78
+ def bar (_ , __ ):
79
+ print (' This is the bar target' )
80
+
81
+
82
+ @target (depends = [' test' ])
83
+ def all (_ , __ ): pass
84
+
69
85
```
70
86
71
87
- Make it executable
@@ -78,6 +94,7 @@ chmod +x ./buildme
78
94
79
95
``` console
80
96
$ ./buildme hello
97
+ This from test
81
98
Namespace()
82
99
================================================================================
83
100
[CMD]: echo Hello World
@@ -86,38 +103,25 @@ Hello World
86
103
code=0
87
104
```
88
105
89
- ``` console
90
- $ ./buildme hello test --release=0
91
- Namespace(release='0')
92
- ================================================================================
93
- [CMD]: echo Hello World
94
- Hello World
95
- ================================================================================
96
- code=0
97
- release is zero
98
- This from test
99
- ```
100
-
101
106
> Order matters
102
107
103
108
``` console
104
- $ ./buildme test hello --release=0
105
- release is zero
106
- This from test
107
- Namespace(release='0')
108
- ================================================================================
109
- [CMD]: echo Hello World
110
- Hello World
111
- ================================================================================
112
- code=0
109
+ $ ./buildme foo bar
110
+ This is the foo target
111
+ This is the bar target
112
+
113
+ $ ./buildme bar foo
114
+ This is the bar target
115
+ This is the foo target
116
+
113
117
```
114
118
115
119
- Helper functions
116
120
117
121
` buildme ` has currently two helper functions
118
122
119
123
``` python
120
- from buildme import mkdir, touch
124
+ from buildme import mkdir, touch, rmdir, rm, get_files_in_dir
121
125
```
122
126
123
127
# Bye....
0 commit comments