marcomaroni-github / twitter-to-bluesky

Import all tweets exported from X/Twitter to a Bluesky account.
Other
499 stars 35 forks source link

command line args support #60

Closed clemensv closed 1 week ago

clemensv commented 1 week ago

This PR consolidates the existing evaluation of environment variables into main() and introduces parameters into the utility functions where the environment is currently referenced directly.

The main() function uses yargs to parse parameters off the command line, with default values taken from the existing environment parameters. The app should thus run as before when using the .env file or explicitly set environment variables.

when using "npm start", the parameters must be passed by two (!) sets of double-dashes, e.g.

npm start -- -- npm run start -- -- --twitter-handles clemensv --bluesky-username clemens-archive.vasters.com --archive-folder m:\twitter --bluesky-password ********** --min-date 2015-08-21

That's a "feature" of npm, not of the script.

This is in prep for bundling the app into a self-contained executable.

marcomaroni-github commented 1 week ago

Great job @clemensv, do you update the readme? Thanks a lot!

clemensv commented 1 week ago

Sure. I'll update the README.md in next couple of hours.

clemensv commented 1 week ago

@marcomaroni-github README has been added. Please review and try it out before merging.

marcomaroni-github commented 1 week ago

@clemensv I have tried this command line

npm run start -- -- --archive-folder C:/Temp/twitter-archive-2024-04-08 --bluesky-username bsky-bot-test.bsky.social --bluesky-password 123 --twitter-handles marcomaroni --min-date '2023-08-27T03:12:49.393Z' --max-date '2023-08-28T03:12:49.393Z' --simulate

but it responds with:

Missing required arguments: archive-folder, bluesky-username, bluesky-password

clemensv commented 1 week ago

@clemensv I have tried this command line

npm run start -- -- --archive-folder C:/Temp/twitter-archive-2024-04-08 --bluesky-username bsky-bot-test.bsky.social --bluesky-password 123 --twitter-handles marcomaroni --min-date '2023-08-27T03:12:49.393Z' --max-date '2023-08-28T03:12:49.393Z' --simulate

Does node app.js --archive-folder C:/Temp/twitter-archive-2024-04-08 --bluesky-username bsky-bot-test.bsky.social --bluesky-password 123 --twitter-handles marcomaroni --min-date '2023-08-27T03:12:49.393Z' --max-date '2023-08-28T03:12:49.393Z' --simulate work for you?

I'm on Node 22

marcomaroni-github commented 1 week ago

Does node app.js --archive-folder C:/Temp/twitter-archive-2024-04-08 --bluesky-username bsky-bot-test.bsky.social --bluesky-password 123 --twitter-handles marcomaroni --min-date '2023-08-27T03:12:49.393Z' --max-date '2023-08-28T03:12:49.393Z' --simulate work for you?

Yes, calling node directly it works, and I'm on node 20.12.1

clemensv commented 1 week ago

Then it's some change in behavior in npm, I assume

marcomaroni-github commented 1 week ago

I updated npm to 10.9 (I had 10.5) and now it works!

clemensv commented 1 week ago

Are you going to merge it?

ricounet67 commented 2 days ago

I have the same issue (missing required arguments) and on Sequoia, with npm@10.9.1 and node.js v23.2.0 I tried with the command line and with a .env file, same result