-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from jontze/release/v0.2.1
Release v0.2.1
- Loading branch information
Showing
42 changed files
with
928 additions
and
574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Cargo Audit | ||
on: | ||
schedule: | ||
- cron: 0 8 * * 1,3,5 # At 08:00 on Monday, Wednesday, and Friday | ||
|
||
jobs: | ||
audit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/audit-check@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,7 @@ | ||
[package] | ||
name = "cadency" | ||
version = "0.2.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
env_logger = "0.9.0" | ||
log = "0.4.14" | ||
reqwest = "0.11.6" | ||
thiserror = "1.0.30" | ||
|
||
[dependencies.serenity] | ||
version = "0.11.5" | ||
default-features = false | ||
features = ["client", "gateway", "rustls_backend", "model", "voice", "cache"] | ||
|
||
[dependencies.tokio] | ||
version = "1.13.0" | ||
features = ["macros", "rt-multi-thread"] | ||
|
||
[dependencies.songbird] | ||
version = "0.3.0" | ||
features = ["builtin-queue"] | ||
|
||
[dependencies.serde] | ||
version = "1.0.130" | ||
features = ["derive"] | ||
[workspace] | ||
members = [ | ||
"cadency_core", | ||
"cadency_codegen", | ||
"cadency_commands", | ||
"cadency" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "cadency" | ||
version = "0.2.1" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
env_logger = "0.9.0" | ||
log = "0.4.14" | ||
|
||
[dependencies.cadency_core] | ||
path = "../cadency_core" | ||
|
||
[dependencies.cadency_commands] | ||
path = "../cadency_commands" | ||
|
||
[dependencies.tokio] | ||
version = "1.13.0" | ||
features = ["macros", "rt-multi-thread"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#[macro_use] | ||
extern crate log; | ||
#[macro_use] | ||
extern crate cadency_core; | ||
|
||
use cadency_commands::{ | ||
Fib, Inspire, Now, Pause, Ping, Play, Resume, Skip, Slap, Stop, Tracks, Urban, | ||
}; | ||
use cadency_core::Cadency; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
env_logger::init(); | ||
|
||
let commands = setup_commands![ | ||
Fib::default(), | ||
Inspire::default(), | ||
Now::default(), | ||
Pause::default(), | ||
Ping::default(), | ||
Play::default(), | ||
Resume::default(), | ||
Skip::default(), | ||
Slap::default(), | ||
Stop::default(), | ||
Tracks::default(), | ||
Urban::default(), | ||
]; | ||
let mut cadency = Cadency::default() | ||
.await | ||
.expect("To init Cadency") | ||
.with_commands(commands) | ||
.await; | ||
if let Err(why) = cadency.start().await { | ||
error!("Client error: {:?}", why); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "cadency_codegen" | ||
version = "0.2.1" | ||
edition = "2021" | ||
|
||
[lib] | ||
proc_macro = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
quote = "1.0.21" | ||
syn = "1.0.99" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
pub(crate) mod command { | ||
use proc_macro::TokenStream; | ||
use syn::{ItemFn, Stmt}; | ||
|
||
fn log_command_usage() -> Result<Stmt, syn::Error> { | ||
syn::parse( | ||
quote!( | ||
debug!("Execute {} command", self.name()); | ||
) | ||
.into(), | ||
) | ||
} | ||
|
||
fn add_start_log(function: &mut ItemFn) { | ||
let logger = log_command_usage().expect("Failed to parse log statement"); | ||
function.block.stmts.insert(0, logger); | ||
} | ||
|
||
pub(crate) fn complete_command(mut function: ItemFn) -> TokenStream { | ||
add_start_log(&mut function); | ||
quote!( | ||
#function | ||
) | ||
.into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use proc_macro::TokenStream; | ||
use syn::DeriveInput; | ||
|
||
pub(crate) fn impl_command_baseline(derive_input: DeriveInput) -> TokenStream { | ||
let struct_name = derive_input.ident; | ||
quote! { | ||
use cadency_core::{self, CadencyCommandBaseline}; | ||
impl cadency_core::CadencyCommandBaseline for #struct_name { | ||
fn name(&self) -> String { | ||
String::from(stringify!(#struct_name)).to_lowercase() | ||
} | ||
|
||
fn description(&self) -> String { | ||
self.description.to_string() | ||
} | ||
|
||
fn options(&self) -> &Vec<CadencyCommandOption> { | ||
self.options.as_ref() | ||
} | ||
} | ||
} | ||
.into() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#[macro_use] | ||
extern crate quote; | ||
|
||
use proc_macro::TokenStream; | ||
use syn::{parse_macro_input, DeriveInput, ItemFn}; | ||
|
||
mod attribute; | ||
mod derive; | ||
|
||
#[proc_macro_derive(CommandBaseline)] | ||
pub fn derive_command_baseline(input_item: TokenStream) -> TokenStream { | ||
// Parse token stream into derive syntax tree | ||
let tree: DeriveInput = parse_macro_input!(input_item as DeriveInput); | ||
// Implement command trait | ||
derive::impl_command_baseline(tree) | ||
} | ||
|
||
#[proc_macro_attribute] | ||
pub fn command(_: TokenStream, input_item: TokenStream) -> TokenStream { | ||
// Parse function | ||
let input_function = parse_macro_input!(input_item as ItemFn); | ||
// Return modified function | ||
attribute::command::complete_command(input_function) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[package] | ||
name = "cadency_commands" | ||
version = "0.2.1" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
log = "0.4.14" | ||
reqwest = "0.11.6" | ||
|
||
[dependencies.serde] | ||
version = "1.0.130" | ||
features = ["derive"] | ||
|
||
[dependencies.serenity] | ||
version = "0.11.5" | ||
default-features = false | ||
features = ["client", "gateway", "rustls_backend", "model", "voice", "cache"] | ||
|
||
[dependencies.songbird] | ||
version = "0.3.0" | ||
features = ["builtin-queue", "yt-dlp"] | ||
|
||
[dependencies.cadency_core] | ||
path = "../cadency_core" | ||
|
||
[dependencies.cadency_codegen] | ||
path = "../cadency_codegen" | ||
|
||
[dev-dependencies.tokio] | ||
version = "1.13.0" | ||
features = ["macros", "rt-multi-thread"] | ||
|
||
[dev-dependencies.cadency_codegen] | ||
path = "../cadency_codegen" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.