@@ -29,6 +29,14 @@ def get_commands():
2929
3030@app .get ("/command" )
3131def get_commands (search : str = None ):
32+ """
33+ It returns a list of commands that match the search term
34+
35+ :param search: str = None
36+ :type search: str
37+ :return: A JSONResponse object with the data from the command file.
38+ """
39+
3240 if search :
3341 result = [
3442 item
@@ -42,24 +50,59 @@ def get_commands(search: str = None):
4250
4351@app .post ("/command" )
4452def create_command (command : CommandSchema ):
53+ """
54+ Create a new command
55+
56+ :param command: CommandSchema
57+ :type command: CommandSchema
58+ :return: A JSONResponse object with a message and a status code.
59+ """
60+
4561 Command .new (** command .dict ())
4662 return JSONResponse ({"msg" : "Command created" }, status_code = 200 )
4763
4864
4965@app .patch ("/command" )
5066def edit_command (old_title : str , command : CommandSchema ):
67+ """
68+ It takes a string and a CommandSchema object, and then edits the command with the old title to the new command
69+
70+ :param old_title: The title of the command you want to edit
71+ :type old_title: str
72+ :param command: CommandSchema - This is the new command that will be used to replace the old one
73+ :type command: CommandSchema
74+ :return: A JSONResponse object with a message and a status code.
75+ """
76+
5177 Command .edit (old_title , command .dict ())
5278 return JSONResponse ({"msg" : "Command edited" }, status_code = 200 )
5379
5480
5581@app .delete ("/command" )
5682def delete_command (command : CommandSchema ):
83+ """
84+ It deletes a command from the database
85+
86+ :param command: CommandSchema - this is the parameter that will be passed to the function
87+ :type command: CommandSchema
88+ :return: A JSONResponse object with a message and a status code.
89+ """
90+
5791 Command .remove (command .dict ())
5892 return JSONResponse ({"msg" : "Command removed" }, status_code = 200 )
5993
6094
6195@app .get ("/test-command" )
6296def test_command (trigger : str ):
97+ """
98+ It takes a trigger as a parameter, calls the test function in the Command class, and returns a JSON response with the
99+ message and status code
100+
101+ :param trigger: The trigger word for the command
102+ :type trigger: str
103+ :return: A JSONResponse object with a dictionary containing a key "msg" and a value of the message variable.
104+ """
105+
63106 response , status = Command .test ("lenovo" , trigger )
64107 if status == 200 :
65108 message = response .get ('message' )
0 commit comments