diff --git a/CHANGELOG.md b/CHANGELOG.md index dc5a8648a..190fd4124 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- fix: `icloud --username` parameter reported as not an option [#719](https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/719) + ## 1.16.2 (2023-09-30) - fix: send logs to stdout [#697](https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/697) diff --git a/Dockerfile b/Dockerfile index 93232968b..69b0741ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ COPY src src RUN pip3 install -e .[dev] -RUN pyinstaller -y --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata src/starters/exec.py +RUN pyinstaller -y --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd_ex.py FROM alpine:3.18 as runtime @@ -23,9 +23,9 @@ WORKDIR /app ENV TZ="America/Los_Angeles" -COPY --from=build /app/dist/exec . +COPY --from=build /app/dist/icloudpd_ex . -ENTRYPOINT ["/app/exec"] +ENTRYPOINT ["/app/icloudpd_ex"] # RUN set -xe \ # && ln -s /app/icloudpd /usr/local/bin/icloudpd \ diff --git a/pyproject.toml b/pyproject.toml index 72369251d..299fd6f14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,6 +73,7 @@ Homepage="https://github.com/icloud-photos-downloader/icloud_photos_downloader" [project.scripts] icloudpd = "icloudpd.base:main" icloud = "pyicloud_ipd.cmdline:main" +icloudpd_ex = "starters.icloudpd_ex:main" [tool.pytest.ini_options] log_format = "%(levelname)-8s %(message)s" diff --git a/scripts/build_bin_linux b/scripts/build_bin_linux index 17ef8687e..02085a3c4 100755 --- a/scripts/build_bin_linux +++ b/scripts/build_bin_linux @@ -7,4 +7,4 @@ set -euo pipefail pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-linux-$2 pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloud.py --name icloud-$1-linux-$2 -pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/exec.py --name icloudpd-ex-$1-linux-$2 +pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd_ex.py --name icloudpd-ex-$1-linux-$2 diff --git a/scripts/build_bin_macos b/scripts/build_bin_macos index cb8a85a52..99a4c5a66 100755 --- a/scripts/build_bin_macos +++ b/scripts/build_bin_macos @@ -7,4 +7,4 @@ set -euo pipefail pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-macos-$2 pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloud.py --name icloud-$1-macos-$2 -pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/exec.py --name icloudpd-ex-$1-macos-$2 +pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd_ex.py --name icloudpd-ex-$1-macos-$2 diff --git a/scripts/build_bin_windows b/scripts/build_bin_windows index 8ad97d891..65e7b30c4 100755 --- a/scripts/build_bin_windows +++ b/scripts/build_bin_windows @@ -7,4 +7,4 @@ set -euo pipefail pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-windows-$2 pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloud.py --name icloud-$1-windows-$2 -pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/exec.py --name icloudpd-ex-$1-windows-$2 +pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd_ex.py --name icloudpd-ex-$1-windows-$2 diff --git a/src/starters/exec.py b/src/starters/icloudpd_ex.py similarity index 55% rename from src/starters/exec.py rename to src/starters/icloudpd_ex.py index c6e73cb39..650adc19f 100644 --- a/src/starters/exec.py +++ b/src/starters/icloudpd_ex.py @@ -6,58 +6,101 @@ import click # goal0 -- allow experimental flow from cli -# goal1 -- compose auth flow for icloud auth apis that supports 2fa, fido, and works from China +# goal1 -- compose auth flow for icloud auth apis that supports 2fa, fido, +# and works from China # print("Experimenting with authentication") # def make_requestor(): # """ make_requestor :: IO (Request -> Response) """ - + # def make_request_builder(): # """ make_request_builder :: State (a -> Request) """ # def make_response_parser(): # """ make_response_parser :: State (Response -> a) """ + @click.group() def commands(): pass + @commands.command() -def icloud(): +@click.option( + "--username", + default="", + help="Apple ID to Use" +) +@click.option( + "--password", + default="", + help=( + "Apple ID Password to Use; if unspecified, password will be " + "fetched from the system keyring." + ) +) +@click.option( + "-n", "--non-interactive", + default=True, + help="Disable interactive prompts." +) +@click.option( + "--delete-from-keyring", + default=False, + help="Delete stored password in system keyring for this username.", +) +@click.option( + "--domain", + default="com", + help="Root Domain for requests to iCloud. com or cn", +) +def icloud(username, password, non_interactive, delete_from_keyring, domain): """Legacy iCloud utils (keyring)""" + # raise Exception("blah") icloud_main(sys.argv[2:]) + @commands.command() -@click.argument('appleid') #, help="AppleID of the account to use") -@click.argument('target') #, help="Target path template") +@click.argument('appleid') # , help="AppleID of the account to use") +@click.argument('target') # , help="Target path template") def copy(appleid, target): """Copy assets from iCloud to local storage""" + @commands.command() def move(): """Move assets from iCloud to local storage""" + @commands.group() def auth(): """Manages persistant credentials""" + @auth.command() -@click.argument('appleid') #, help="AppleID of the account to use") +@click.argument('appleid') # , help="AppleID of the account to use") def add(appleid): """Add credentials to keyring""" + @auth.command() -@click.argument('appleid') #, help="AppleID of the account to use") +@click.argument('appleid') # , help="AppleID of the account to use") def delete(appleid): """Delete credentials from keyring""" + @commands.group() def watch(): """Watch for iCloud changes""" -if __name__ == "__main__": + +def main(): commands.add_command(icloudpd_main, name="icloudpd") watch.add_command(copy) watch.add_command(move) commands() + + +if __name__ == "__main__": + main()