build notesync app
This commit is contained in:
parent
c5046ad9e7
commit
a689ba1758
|
@ -2,10 +2,14 @@ import frontmatter
|
||||||
import click
|
import click
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
import shutil
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option("--input-dir", "-i", required=True)
|
@click.option("--input-dir", "-i", required=True)
|
||||||
def main(input_dir: str):
|
@click.option('--output-dir','-o', required=True)
|
||||||
|
def main(input_dir: str, output_dir):
|
||||||
|
|
||||||
|
public_files = []
|
||||||
|
|
||||||
for file in glob.glob(os.path.join(input_dir,"**","*.md")):
|
for file in glob.glob(os.path.join(input_dir,"**","*.md")):
|
||||||
|
|
||||||
|
@ -14,6 +18,18 @@ def main(input_dir: str):
|
||||||
|
|
||||||
if data.get('public'):
|
if data.get('public'):
|
||||||
print(f"public file {file}")
|
print(f"public file {file}")
|
||||||
|
public_files.append(file)
|
||||||
|
|
||||||
|
|
||||||
|
for file in public_files:
|
||||||
|
path = file[len(input_dir):]
|
||||||
|
out_path = os.path.join(os.path.abspath(output_dir), path)
|
||||||
|
|
||||||
|
if not os.path.exists(os.path.dirname(out_path)):
|
||||||
|
print(f"mkdir {os.path.dirname(out_path)}")
|
||||||
|
os.makedirs(os.path.dirname(out_path), exist_ok=True)
|
||||||
|
|
||||||
|
shutil.copy(file, out_path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue