office: usage text, no session before the project is known good; commands on PATH

This commit is contained in:
Sam
2026-11-12 12:10:57 +11:00
parent 7b2cccf2ff
commit a129c4e0c3
9 changed files with 616 additions and 5 deletions

View File

@@ -236,8 +236,26 @@ def run_on_remote(host, folder, opts):
return 0
USAGE = """office — open a folder as a project
office <folder> --project "<Name>" adopt a project Paperclip already has
office <folder> --new "<Name>" create the Paperclip project too
office <folder> --project "<Name>" --host nixos-desktop the folder is on that machine
office <folder> --dry say what would happen, write nothing
The folder and the session live on the same machine. If you are typing inside the
session, on the machine that owns the folder, it is just: office <folder>.
"""
def main():
opts = parse(sys.argv[1:])
argv = sys.argv[1:]
if not argv or "-h" in argv or "--help" in argv:
h.say(USAGE.strip())
return 0
opts = parse(argv)
if opts["folder"] in ("", "."):
raise h.Refused(2, "give the folder: office <folder> --project \"<Name>\" (office --help)")
folder = os.path.abspath(os.path.expanduser(opts["folder"]))
if not os.path.isdir(folder):
raise h.Refused(2, "no folder at %s" % folder)
@@ -277,9 +295,6 @@ def main():
h.say("dry run: nothing was written")
return 0
if not opts["no_switch"]:
ensure_session(session, folder)
if opts["host"] and opts["host"] not in (pj.this_machine(), pj.this_machine().split(".")[0]):
# Only a note, because the panes are built by the machine that owns them.
h.say("host: %s (build the pages there)" % host)
@@ -323,6 +338,9 @@ def main():
pj.save(folder, cfg)
h.say("wrote %s" % pj.path(folder))
if not opts["no_switch"]:
ensure_session(session, folder)
pj.register(cfg, proj["name"])
h.say("recorded in %s" % pj.REGISTRY)