-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a script to automatically set the version in
Cargo.toml
- Loading branch information
Showing
4 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# From https://github.com/Intreecom/scyllapy/blob/05fdab32dd7468c26533de5fdfe9627fa3e38445/scripts/version_bumper.py | ||
|
||
import re | ||
import argparse | ||
from pathlib import Path | ||
|
||
|
||
def parse_args() -> argparse.Namespace: | ||
"""Parse command line arguments.""" | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--target", | ||
"-t", | ||
dest="target", | ||
type=Path, | ||
default="Cargo.toml", | ||
) | ||
parser.add_argument("version", type=str) | ||
return parser.parse_args() | ||
|
||
|
||
def main() -> None: | ||
"""Main function.""" | ||
args = parse_args() | ||
with args.target.open("r") as f: | ||
contents = f.read() | ||
|
||
contents = re.sub( | ||
r"version\s*=\s*\"(.*)\"", | ||
f'version = "{args.version}"', | ||
contents, | ||
count=1, | ||
) | ||
|
||
with args.target.open("w") as f: | ||
f.write(contents) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters