Skip to content

Conversation

@czoido
Copy link
Collaborator

@czoido czoido commented Apr 4, 2025

WIP to have more visibility over installation origins and also cleaning up a bit...

  • Group commands by origin (tome) when listing them
  • Add command extension to shell scripts, so that you can disambiguate when you have one bat and one sh shell script installed in the same tome.
  • Load commands with deterministic order, so that when two commands collide by name the oldest one is the one preseerved.
  • Better uninstall, now if the user does a "tome uninstall " and exception guiding the user is raised

This is how tome list would look now:

tome list

📖 /Users/.../tome-examples

  🐮 utils commands
     utils:get-folder-contents (e)  Show the content of files that match the given patterns, searching recursively in subdirectories.
     utils:send-mail (e)            Send email with content

📖 [email protected]:owner/test-commands.git

  ☁️  aws commands
      aws:download-s3                Download a file from an S3 bucket in AWS.
      aws:upload-s3                  Upload a file to an S3 bucket in AWS.

  📅 calendar commands
     calendar:events                Manage your calendar events.

  🌐 network commands
     network:ping-bat               Script to ping an IP address or URL. Arguments: <IP or URL>.
     network:ping-sh                Script to ping an IP address or URL. Arguments: <IP or URL>.
     network:traceroute-bat         Script to perform a traceroute to an IP address or URL. Arguments: <IP or URL>.
     network:traceroute-sh          Script to perform a traceroute to an IP address or URL. Arguments: <IP or URL>.

  📁 file commands
     file:compress                  Compress files into a zip archive.
     file:decompress                Decompress files from a zip archive.
     file:decrypt                   Decrypt a file.
     file:encrypt                   Encrypt a file.

  💰 finance commands
     finance:currency               Convert currency from one unit to another using current exchange rates.
     finance:stocks                 Description of the command.

@czoido czoido changed the title Some improvements [WIP] some improvements Apr 4, 2025
@czoido czoido marked this pull request as ready for review April 9, 2025 10:56

built_in_commands = [cmd_info for cmd_info in self._commands.values() if cmd_info.type == CommandType.built_in]

print_grouped_commands({None: {None: built_in_commands}})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

built-in commands do not have origin or namespace so they are None


basename = os.path.basename(script)[len("tome_") :]
self._name = os.path.splitext(basename)[0].replace("_", "-")
self._name = basename.replace("_", "-").replace(".", "-")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shell commands will have the -sh or -bat suffix added to the name

Copy link
Collaborator

@AbrilRBS AbrilRBS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments, otherwise looks good to-me

tome_scripts_path = TomePaths(self._tome_api.cache_folder).scripts_path
for origin in os.listdir(tome_scripts_path):

# FIXME: should we error out if commands overlap? should we allow multiple commands with the same name?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that at least a warning should be produced

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I wanted a warning too, but the problem is that for the easy way of showing the warning it will be shown everytime tome is invoked, the ideal would be to show that on install but when installing the commands are not loaded...

@czoido czoido merged commit 3f01565 into main Apr 11, 2025
13 checks passed
@czoido czoido deleted the czoido/some-improvements branch May 5, 2025 19:16
@czoido czoido changed the title [WIP] some improvements Group commands by origin and some other improvements Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants