Skip to content

Conversation

@MoDarK-MK
Copy link

@MoDarK-MK
Copy link
Author

Hello
I hope you are well
This is my update for a better look and easier installation
If you like you can add it
Thank you

@MoDarK-MK
Copy link
Author

MoDarK-MK commented Oct 16, 2025

Also in this case we have traceback

@MoDarK-MK
Copy link
Author

MoDarK-MK commented Oct 16, 2025

if you like this tell me to code more

@D3vil0p3r
Copy link
Contributor

@enty8080 can you give a look to this please? Also, the project needs to have at least requirements.txt file as in this PR or a pyproject.toml file instead of the setup.py.

@MoDarK-MK
Copy link
Author

Hi, I hope you are well
I will look into it and send you the result
Thank you
I will send you all the updates for this tool

@MoDarK-MK
Copy link
Author

Hello again
I did some things to make the tool better

@D3vil0p3r
Copy link
Contributor

D3vil0p3r commented Oct 17, 2025

Hello again I did some things to make the tool better

Can you standardize it by using pyproject.toml approach instead of install.py?

@enty8080
Copy link
Member

@MoDarK-MK Why did you add install.py and uninstall.py when you can easily install Ghost with pip by providing URL to repository as an argument?

@enty8080
Copy link
Member

@MoDarK-MK Traceback encountered identifying attempt to inject custom printing methods instead of using badges:

(ghost)> ?
                                                                                              ERROR
  An error occurred: Console.print_empty() got an unexpected keyword argument 'end'!

Traceback (most recent call last):
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 545, in loop
    line = self.onecmd(line)
           ^^^^^^^^^^^^^^^^^
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 658, in onecmd
    getattr(self, 'do_' + args[0])(args)
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 431, in do_help
    self.print_empty(buffer, end='')
TypeError: Console.print_empty() got an unexpected keyword argument 'end'
(ghost)> exit
Traceback (most recent call last):
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 545, in loop
    line = self.onecmd(line)
           ^^^^^^^^^^^^^^^^^
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 658, in onecmd
    getattr(self, 'do_' + args[0])(args)
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/ghost/core/console.py", line 196, in do_exit
    raise EOFError
EOFError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/felix/Ghost/sas/Ghost/ghost/__init__.py", line 37, in <module>
    cli()
  File "/Users/felix/Ghost/sas/Ghost/ghost/__init__.py", line 35, in cli
    console.shell()
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/ghost/core/console.py", line 300, in shell
    self.loop()
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 549, in loop
    self.print_empty(end='')
TypeError: Console.print_empty() got an unexpected keyword argument 'end'

@MoDarK-MK
Copy link
Author

Convenience for non-technical users
UI

@MoDarK-MK Why did you add install.py and uninstall.py when you can easily install Ghost with pip by providing URL to repository as an argument?

@enty8080
Copy link
Member

@MoDarK-MK To be honest, I think even non-technical users can read README.md with installation instructions (in current state it is single command)

@MoDarK-MK
Copy link
Author

@MoDarK-MK Traceback encountered identifying attempt to inject custom printing methods instead of using badges:

(ghost)> ?
                                                                                              ERROR
  An error occurred: Console.print_empty() got an unexpected keyword argument 'end'!

Traceback (most recent call last):
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 545, in loop
    line = self.onecmd(line)
           ^^^^^^^^^^^^^^^^^
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 658, in onecmd
    getattr(self, 'do_' + args[0])(args)
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 431, in do_help
    self.print_empty(buffer, end='')
TypeError: Console.print_empty() got an unexpected keyword argument 'end'
(ghost)> exit
Traceback (most recent call last):
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 545, in loop
    line = self.onecmd(line)
           ^^^^^^^^^^^^^^^^^
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 658, in onecmd
    getattr(self, 'do_' + args[0])(args)
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/ghost/core/console.py", line 196, in do_exit
    raise EOFError
EOFError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/felix/Ghost/sas/Ghost/ghost/__init__.py", line 37, in <module>
    cli()
  File "/Users/felix/Ghost/sas/Ghost/ghost/__init__.py", line 35, in cli
    console.shell()
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/ghost/core/console.py", line 300, in shell
    self.loop()
  File "/Users/felix/miniforge3/lib/python3.12/site-packages/badges/cmd.py", line 549, in loop
    self.print_empty(end='')
TypeError: Console.print_empty() got an unexpected keyword argument 'end'
def print_empty(self, message: str = "", end: str = "\n") -> None:
    self.rich.print(message)

replace this code
console.py

@MoDarK-MK
Copy link
Author

@MoDarK-MK To be honest, I think even non-technical users can read README.md with installation instructions (in current state it is single command)

if you dont like it we can remove it but try it

@D3vil0p3r
Copy link
Contributor

ps: I am still testing

@MoDarK-MK
Copy link
Author

Screenshot_2025-10-17_20_22_36

@MoDarK-MK
Copy link
Author

its working

@MoDarK-MK
Copy link
Author

It's 4am in my country
If I die, I'll be back soon

@D3vil0p3r
Copy link
Contributor

Omg I did finally. There is a missing main function that we need to add. So @MoDarK-MK please do the following things

@MoDarK-MK
Copy link
Author

im here

@D3vil0p3r
Copy link
Contributor

1- Remove the entire content from __init__.py BUT without deleting it.
2- Still inside ghost folder, create a file called __main__.py with the following content:

"""
MIT License

Copyright (c) 2020-2024 EntySec

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

from ghost.core.console import Console

def cli() -> None:
    """ Ghost Framework command-line interface.

    :return None: None
    """

    console = Console()
    console.shell()

if __name__ == "__main__":
    cli()

@MoDarK-MK
Copy link
Author

its ok now

@D3vil0p3r
Copy link
Contributor

Just to explain the reason of this:

  • Before, if a main function is not present and CLI is defined in __init__.py, ghost.cli() is importable, ok, but it is potentially heavy and could have side effects.
  • By the main approach, python -m ghost works out of the box. Keeps imports clean: import ghost stays lightweight.

So, now, the update to pyproject.toml is complete. The last point depends on @enty8080 if he would like to keep its old style or the new style proposed by you @MoDarK-MK

@MoDarK-MK
Copy link
Author

Thank you man
You helped me a lot tonight.

@MoDarK-MK
Copy link
Author

Thank you both.

@enty8080
Copy link
Member

I'll review everything in the morning. Thank you again for your contribution!

@D3vil0p3r
Copy link
Contributor

D3vil0p3r commented Oct 18, 2025

Thank you man You helped me a lot tonight.

There is a more robust and standardized approach that would be beneficial for the future. At this point :D @MoDarK-MK let's do that.

@D3vil0p3r
Copy link
Contributor

On ghost folder, create a file cli.py with the following code:

from ghost.core.console import Console

def main() -> int:
    Console().shell()
    return 0

Then, edit __main__.py and it should have only this code:

from .cli import main

if __name__ == "__main__":
    raise SystemExit(main())

Then, edit __init__.py and it should have only this code:

"""
MIT License

Copyright (c) 2020-2024 EntySec

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

__version__ = "…"

Finally, inside pyproject.toml, change ghost = "ghost.cli" to ghost = "ghost.cli:main".

Why this is more robust?

  • Because standard and robust for the future
  • Allow to run ghost on different manners:
    • As a module: python -m ghost
    • As a direct file: python ghost/__main__.py
    • Importing programmatically: from ghost.cli import main; main()

@D3vil0p3r
Copy link
Contributor

D3vil0p3r commented Oct 18, 2025

@MoDarK-MK it works. Just one thing about the interface:

image

Color codes are not expanded correctly (look at [1m[4m, [1m[0m or [1m).

Furthermore, uninstall.py is not needed. pip can easily be used to uninstall it. Keeping uninstall.py is just a waste for our eyes on the repo. Repo must be kept clean and simple.

@enty8080 regardless the decision of the interface, I suggest strongly to implement at least the changes done on ghost/cli.py, ghost/__init__.py and ghost/__main__.py, and on pyproject.toml and removing setup.py.

In case you will accept the new proposed interface, remember to add the rich dependency inside pyproject.toml.

@MoDarK-MK
Copy link
Author

ok i try to solve it

@D3vil0p3r
Copy link
Contributor

@enty8080 did you get a look this morning?

@enty8080
Copy link
Member

No, didn't have time

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.

3 participants